[JASS] Issue with making a function in custom script

Level 23
Joined
Mar 15, 2012
Messages
2,669
So I decided to explore trying to make custom functions with CS in GUI however this pops up an error.

Apparently it expects a function name. . .

[trigger=]
Events
Conditions
Actions
Custom script: endfunction
Custom script: function Grow takes nothing returns nothing
Animation - Change growu's size to (growsize%, 100.00%, 100.00%) of its original size
[/trigger]

[trigger=]
Events
Time - Every 0.10 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Loop - Actions
Set growu = (Picked unit)
Set growsize = (growsize + 20.00)
Custom script: call Grow()
Set growu = No unit
[/trigger]
 
Level 22
Joined
Sep 24, 2005
Messages
4,820
That's because the second trigger's script is above the first one (GUI triggers are converted to a big single jass script when saved); Try deleting the second trigger (copy it first) then save the map, then paste it and save; If the error persists, try deleting the second trigger and manually redoing it.

EDIT: A better solution is to convert that GUI trigger to jass and then paste it to the map header.
 
Level 22
Joined
Sep 24, 2005
Messages
4,820
You should create the trigger with the function Grow first, then the second (and the succeeding ones too) one that will use that function. Arranging it won't do a thing as the triggers are ordered in script according to it's creation.
 
Level 4
Joined
Nov 27, 2012
Messages
85
Trigger orders get rearranged all the time when compiling

You can use this in the 2nd trigger
JASS:
call ExecuteFunc("Grow")
ExecuteFunc will call any function no matter where it is

But to be honest, those 2 triggers are kinda useless and would be faster a 1 GUI trigger
 
Level 23
Joined
Mar 15, 2012
Messages
2,669
Trigger orders get rearranged all the time when compiling

You can use this in the 2nd trigger
JASS:
call ExecuteFunc("Grow")
ExecuteFunc will call any function no matter where it is

But to be honest, those 2 triggers are kinda useless and would be faster a 1 GUI trigger

Thank you, is there any problems/dis-advantages with ExecuteFunc?
 
Thank you, is there any problems/dis-advantages with ExecuteFunc?
Yes, when using string concatenation with the input string, your map will break the "Compress Names" feature of Vexorians Map Optimizer.

I usually recommend to stay away from ExecuteFunc. It's slow and doesn't work well with Map Optimizer. Also, it circumvents the compiler from detecting if your input is wrong (i.e. if you made a typo).
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Optimizer thing is just a myth or it was an older bug which is fixed.(Third option I am wrong but no)
 
Top