Magthridon96
Member
- Reaction score
- 2
I submitted this a while ago on The Hive and thought it
would be appropriate to post it here as well.
What it does:
- Replaces Blizzard's "CreateTrigger - RegisterEvent - AddCondition - AddAction" with a simple "RegisterPlayerUnitEvent"
- Optimizes scripts (You know what slows down your map? Hundreds upon hundreds of triggers firing.)
- This also reduces the amount of RAM used.
Special Thanks to Bribe, azlier and BBQ
Feel free to comment..
would be appropriate to post it here as well.
What it does:
- Replaces Blizzard's "CreateTrigger - RegisterEvent - AddCondition - AddAction" with a simple "RegisterPlayerUnitEvent"
- Optimizes scripts (You know what slows down your map? Hundreds upon hundreds of triggers firing.)
- This also reduces the amount of RAM used.
Special Thanks to Bribe, azlier and BBQ
JASS:
/**************************************************************
*
* RegisterPlayerUnitEvent
* v4.2.0.0
* By Magtheridon96
*
* I would like to give a special thanks to Bribe, azlier
* and BBQ for improving this library. For modularity, it only
* supports player unit events.
*
* Functions passed to RegisterPlayerUnitEvent must
* return false. They can return nothing as well.
*
* Disclaimer:
* -----------
*
* - Don't use TriggerSleepAction inside registered code.
*
* API:
* ----
*
* function RegisterPlayerUnitEvent
* takes
* playerunitevent whichEvent : The event you would like to register
* code whichFunction : The code you would like to register
* returns
* nothing
*
* - Registers code that will execute when an event fires.
*
**************************************************************/
library RegisterPlayerUnitEvent // Special Thanks to Bribe and azlier
globals
private trigger array t
endglobals
function RegisterPlayerUnitEvent takes playerunitevent p, code c returns nothing
local integer i = GetHandleId(p)
local integer k = 15
if t<i> == null then
set t<i> = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(t<i>, Player(k), p, null)
exitwhen k == 0
set k = k - 1
endloop
endif
call TriggerAddCondition(t<i>, Filter(c))
endfunction
endlibrary</i></i></i></i>
Feel free to comment..