• 🏆 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!

[JASS] textmacro question

Status
Not open for further replies.
This is my first textmacro:

JASS:
    //! textmacro Multi takes count, id, x, y, rndX, rndY
        set i = $count$
        set cx = $x$
        set cy = $y$
        loop
            if(not($rndX$ == 0. and $rndY$ == 0.))then
                set cx = GetRandomReal($x$,$rndX$)
                set cy = GetRandomReal($y$,$rndY$)
            endif
            call CreateUnit(BAD,$id$,cx,cy,GetRandomReal(0.,360.))
            set i = i - 1
            exitwhen(i == 0)
        endloop
    //! endtextmacro

Calling it like this:

JASS:
function somefunction takes nothing returns nothing
    local integer i
    local real cx
    local real cy
    //! runtextmacro Multi ("rand1","5","'nspp'","-5776.","-1952.","0.","0.")
endfunction

Am I doing it right?
 
Last edited:
From my experiences, it is the only way to apply changes to different arrays that use the same evaluations other than tediously typing each array its own function. Like if you want to evaluate to see if unit array blah has a dead unit, you can't simply tell the function which array you're using. In a text macro, you auto-generate the function, which makes it extremely easy to create it for a lot of arrays. In turn, using textmacros for similar segments consolidates them, so if you need to check for an error in that widespread code, you only have to work with the one textmacro and apply the changes globally.
 
Status
Not open for further replies.
Top