• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

2 JASS and 2 vJASS questions

Status
Not open for further replies.
Level 17
Joined
Dec 11, 2014
Messages
2,004
2 JASS, 1 Zinc and 2 vJASS questions

These questions might sound noobish but I'm stuck on them.

JASS Questions:


  1. What are widgets? [Got it]
  2. What are boolexprs?

vJASS Questions:


  1. Can textmacros be dynamic? Like:
    JASS:
    //! textmacro TM takes STR
    call BJDebugMsg("$STR$")
    //! endtextmacro
    
    function test takes string s returns nothing
    //! runtextmacro TM(s)
    endfunction
  2. I don't get it... What is extending structs?
    JASS:
    struct ExtendingStruct // I get this one
    endstruct
    
    struct x extends ExtendingStruct // I get it too
    endstruct
    
    struct y extends array // I don't get this one
    endstruct

Zinc Question:

I've tried to learn 2D arrays when I wanted to learn Java/C#, but I failed.

Can someone tutor me multidimensional/2D arrays?
 
Last edited:
Level 12
Joined
Jan 2, 2016
Messages
973
JASS:
1) From what I've heard - widgets are "objects" - destrucatbles, units, items, etc... It just covers a bigger part of the family.
2) I'm not sure......

vJASS:
1) You can, but it'd look like //! runtextmacro TM("s")
2) I may lie to you about this one, but I think it works like this:
Struct A
real x
endstruct

struct B extends A
real y
endstruct

struct C extends B
real z
endstruct

now A has only .x
B has .x, and .y
C has .x, .y and .z
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
JASS:
1) From what I've heard - widgets are "objects" - destrucatbles, units, items, etc... It just covers a bigger part of the family.
2) I'm not sure......

vJASS:
1) You can, but it'd look like //! runtextmacro TM("s")
2) I may lie to you about this one, but I think it works like this:
JASS:
Struct A
    real x
endstruct

struct B extends A
    real y
endstruct

struct C extends B
    real z
endstruct

now A has only .x
B has .x, and .y
C has .x, .y and .z

Thanks, I got widgets and struct extending struct, but what about struct extending array?

About the textmacro, I think my example was misleading. Check this one:

JASS:
function FuncSimple takes nothing returns nothing
    //things
endfunction

function FuncSimpler takes nothing returns nothing
    //things
endfunction

function FuncMoustache takes nothing returns nothing
    //things
endfunction

//! textmacro meh takes str
call Func$str$
//! endtextmacro

function CallFunc takes string s returns nothing
//! runtextmacro meh(s)
endfunction


//Somewhere in the middle of some script
call CallFunc("Simple")
call CallFunc("Simpler")
call CallFunc("Moustache")
 
Level 11
Joined
Dec 19, 2012
Messages
411
BPower wrote a nice tutorial about struct extending struct : [vJass] Meet vJass - Extending structs

For struct extends array, it just removes all the struct functions like allocate() and deallocate() from it. So you will need to code all things yourself.

Textmacro wouldn't works in that way. It get ran when pjass compiling the code. Not in game.

About boolexpr :
JASS:
function test takes nothing returns boolean
	return GetEnumUnit() == Player(0)
endfunction

function init takes nothing returns nothing
	local boolexpr b = Condition(function test)
	local boolexpr b2 = Filter(function test)
	local group g = CreateGroup()
	
	call GroupEnumUnitsInRange(g, 0, 0, 0, b)
	call GroupEnumUnitsInRange(g, 0, 0, 0, b2) //works as well
endfunction
Mostly, people don't use boolexpr as can hardly find a use for it.
 
Status
Not open for further replies.
Top