HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

ExecuteFunc vs. CreateTrigger

08-24-2006, 04:14 AM#1
EveningStar
Hi,

I'm not very good with performance related questions so I'm throwing this out to people that knows more about it.

I have a map with 50+ heros; each of which has some triggered spells, and thus requiring initialization. I thought of a modular way to implement it, and it is via GameCache storing a list of initialization triggers; however, I'm stuck between using:

Collapse JASS:
function initialize_hero takes integer id returns nothing
  local string s = GetAttachedString("hero", id)
  call ExecuteFunc(s)
endfunction

or

Collapse JASS:
function initialize_hero takes integer id returns nothing
  local trigger t = GetAttachedTrigger("hero", id)
  call ExecuteTrigger(t)
  set t = null
endfunction

Naturally, the 2nd method requires me to create a trigger without an event which initializes the hero with the particular unit id; I was wondering which method is more efficient. Thanks for the help!
08-24-2006, 04:43 AM#2
karukef
I will leave it up to someone with more JASS knowledge than me to answer whether a call to ExecuteTrigger is faster than ExecuteFunc or not, but I can at least say that if you are just calling these functions on initialization (that is, not several times per second), performance means nothing.

It's the difference between 0 seconds and 0 seconds for varying degrees of 0 :)
08-24-2006, 05:02 AM#3
PipeDream
I strongly prefer using triggers/code vars and TriggerExecute because you get a syntax error with a line number instead of an in game crash.
08-24-2006, 08:59 AM#4
EveningStar
Quote:
Originally Posted by PipeDream
I strongly prefer using triggers/code vars and TriggerExecute because you get a syntax error with a line number instead of an in game crash.

so how does the in-game crash occur with ExecuteFunc?
08-24-2006, 09:24 AM#5
DioD
if function not found it will crush
08-24-2006, 10:55 AM#6
blu_da_noob
More clearly: if you pass it a string for which no function exists (I recall someone (Blade?) saying that it doesn't crash if you pass it an empty string anymore).
08-24-2006, 12:47 PM#7
Vexorian
for this case (You already have to store stuff in gamecache) Triggers may work better, the only problem is that code values require the functions to be above, for a general purpose system they are extremely unpractical, but if you are making this for yourself you can survive by using triggers.

When you just want to run a function in a new thread I would always take ExecuteFunc before triggers, in order to use a trigger I would either have to add complexity to the code by creating the trigger on the initialization and saving it in a variable or another storage thing, and that might as well turn to be slower than ExecuteFunc.

Or I would have to create the Trigger and destroy it to prevent the leak, but since the DestroyTrigger bug it is better to avoid such a situation.

Executing a trigger also has the nasty side effect of overwriting GetTriggeringTrigger()