(Stock World Edit/stock JASS) Can you call a function from a different trigger?

Weep

Godspeed to the sound of the pounding
Reaction score
400
Can you call a function that was defined in another trigger, as opposed to the header custom script section, using the unmodified World Editor/non-vJASS? When I try, it errors with "Expected a function name". The trigger with the definition is above the calling trigger.
 

Rainther

I guess I should write something of value here...
Reaction score
61
It may be that the trigger is needed to be called after in order to be first. Perhaps the second trigger "jumps" above the other trigger and forces it to be after?
 

cleeezzz

The Undead Ranger.
Reaction score
268
you could try

call *function name*.evaluate()

ex: call hi.evaluate()

i think that might allow calling the function no matter where it is o_O
 

quraji

zap
Reaction score
144
Short answer: Maybe

Long answer:
You have trigger Atrig, you turn it to custom script, and write a jass function 'A'.
You have trigger Btrig, you turn it to custom script, and write a jass function 'B'.
A wants to call B.

Sometimes this will work, sometimes it won't. The reason is because that in jass you may only call a function if it is above the calling function in the compiled map script. So B would have to be above A in this case. Sometimes WE will place B above A, sometimes it will be below.
A few ways to make sure B can always be called from A:
-Place B in the map header. If A is in a trigger, A will always be able to call B.
-Put both in the map header, with B above A.
-Put both in the same trigger, with B above A.
The lesson is that you can't control which triggers are compiled above others (unless you use vJass).

you could try
call *function name*.evaluate()
i think that might allow calling the function no matter where it is o_O

It says in the post, and the post title "stock JASS" :p
 

quraji

zap
Reaction score
144
oh i didn't know hi.evaluate() was vjass O_O

EVERYTHING with a period is vJASS (besides reals...) :p

Extra note:
In stock JASS, only ExecuteFunc() will allow you to call a function from anywhere, but you can't use arguments/returns.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
The reason is because that in jass you may only call a function if it is above the calling function in the compiled map script. So B would have to be above A in this case. Sometimes WE will place B above A, sometimes it will be below.
Ew. :eek: Well, "call MyFunc()" as a GUI custom script action gives a WE compiler error even though I checked that the trigger defining the function really did end up in war3map.j above the trigger I'm editing... Also, it seems like triggers will always be grouped in order of their category, though the order within the category is random(?).

Extra note:
In stock JASS, only ExecuteFunc() will allow you to call a function from anywhere, but you can't use arguments/returns.
Ew, again. :( Not much better than what I ended up doing (just running the trigger via GUI command and passing all the data through globals). I want my arguments (but I can't have them, it seems). :p

Thanks for the info!
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Use vJass!
So many headaches caused by JASS will go away :thup:
And this is why it would be great if the mods would enable my forum sig so I could leave a permanent note pointing out that I can't implement or code with vJASS because I'm on a Mac. ;)
 

quraji

zap
Reaction score
144
I'm on a Mac. ;)

Are you regretting that decision? :p

Anyways, the real advantage of vJass is the syntax, and the fact that it basically does all the work for you to use the special features (function evaluating/structs/libraries/scopes/etc.). But, it's all JASS in the end, so you can still do anything vJASSers can do...it'll just be harder..and slower.

So, have fun :thup:
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Are you regretting that decision? :p
Never! :p Though I've had notions of virtualizing Windows just for mapping... :nuts:

Anyways, the real advantage of vJass is the syntax, and the fact that it basically does all the work for you to use the special features (function evaluating/structs/libraries/scopes/etc.). But, it's all JASS in the end, so you can still do anything vJASSers can do...it'll just be harder..and slower.
Indeed. However, a few of the things it does (eg. arbitrarily-named globals) can't be done in the World Editor, but only if you were to edit the war3map.j file in the MPQ. But the real real advantage of vJASS is being able to use systems other people wrote in it. :(
 

quraji

zap
Reaction score
144
Indeed. However, a few of the things it does (eg. arbitrarily-named globals) can't be done in the World Editor, but only if you were to edit the war3map.j file in the MPQ. But the real real advantage of vJASS is being able to use systems other people wrote in it. :(

Stop talking about how good it is, you'll depress yourself. Now, excuse me while I go make some structs and things.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top