Chaosy
Tutorial Reviewer
- Joined
- Jun 9, 2011
- Messages
- 13,288
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
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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(...)
). Is it possible to then unhook it at daybreak? I'm trying to get a better sense of exactly how this works, because it could be really useful for avoiding lots of conditionals when working with global gamestates such as time of day, upgrade thresholds, etc.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
