• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Issue with making a function in custom script

Status
Not open for further replies.
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,821
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,821
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
 
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)
 
Status
Not open for further replies.
Top