- Joined
- Sep 26, 2009
- Messages
- 9,534
Bannar contacted me in regards to the Event library being remade into Trigger, moved offsite, having 15 requirements and not even having a standard API across resources anymore thanks to syntax changes over the years.
I wrote this small function for my DamageEngine GUI/vJass hybrid project which is still in the lab. But the standalone function is ready as there isn't much to it, despite that it conforms to all necessary capabilities of an event library.
I wrote this small function for my DamageEngine GUI/vJass hybrid project which is still in the lab. But the standalone function is ready as there isn't much to it, despite that it conforms to all necessary capabilities of an event library.
JASS:
library RealEvent
/*
Made by Bribe
This is a unification of the real variable event in wc3 and clean vJass syntax.
It is made to fill the void created by resources that need an event but want an API
that works without requiring a bunch of libraries.
Tiny API:
CreateRealEventTrigger(string whichVariable, real whichValue, code whichFunction) -> trigger
If you specify a code value, it automatically adds that as a condition,
making this a nice one-liner that also returns the trigger in case you need it.
Since JASS doesn't support pointers but values, the user will need to fire the
event manually, via:
set realVariable = 0.00
set realVariable = eventValue
*/
globals
private trigger tempTrig
endglobals
//You do not need the return value of this function if you have no intention of
//disabling/destroying this trigger from outside of it being run.
function CreateRealEventTrigger takes string variable, real value, code run returns trigger
set tempTrig = CreateTrigger()
call TriggerRegisterVariableEvent(tempTrig, variable, EQUAL, value)
if run != null then
call TriggerAddCondition(tempTrig, Filter(run))
endif
return tempTrig
endfunction
endlibrary