Chaosy
Tutorial Reviewer
- Joined
- Jun 9, 2011
- Messages
- 13,219
I ran over this in a jass script and I have never seen it before, what is that and what does it do?
JASS:
hook
hook
function func takes unit u returns nothing
endfunction
hook KillUnit func
function rawr takes nothing returns nothing
call KillUnit( GetTriggerUnit() )
endfunction
hook RemoveUnit rawr
KillUnit(GetTriggerUnit())
RemoveUnit(...)
function Hello takes nothing returns nothing
call BJDebugMsg("Hello")
endfunction
hook DoNothing Hello
function UseDoNothing takes nothing returns nothing
call DoNothing()// This prints Hello
endfunction
^ Wrong.
As of what edo said,this replaces the function of the function you want to be hooked.
Example:
JASS:function Hello takes nothing returns nothing call BJDebugMsg("Hello") endfunction hook DoNothing Hello function UseDoNothing takes nothing returns nothing call DoNothing()// This prints Hello endfunction
in the example above,DoNothing is replaced with Hello function,losing DoNothing's original function
globals
boolean theTimeIsNow = false
endglobals
function Example takes unit u returns nothing
if ( theTimeIsNow ) then
// do actions
endif
endfunction
hook RemoveUnit Example