Question about hooks

jrhetf4xb

Member
Reaction score
12
A few things came to my mind with hooks but first I want to clarify some things since I've never used them.

What happens with the hooked function? Is it still a valid call even if hooked?
What I mean is this:
JASS:
hook PauseUnit CustomPauseUnit

function CustomPauseUnit takes unit whatever, boolean toPause returns nothing
    set this = asffsafsa
    set that = afsfasfsa
    // etc.
endfunction

Will it still pause the unit AND do all the stuff in my custom function? If not, if I use PauseUnit within my CustomPauseUnit would there be some kind of recursion that would cause it to fail?
 

Laiev

Hey Listen!!
Reaction score
188
the hook just work to you execute some function when some native/bj run... but don't work if some bj/native use the function to callback...

so yes, it will execute first the PauseUnit then will execute ur function


example of limitation of hook:

JASS:
function CustomPauseUnit takes unit whichUnit, boolean pause returns nothing
    call BJDebugMsg(GetUnitName(whichUnit))
endfunction

hook PauseUnit CustomPauseUnit

call PauseUnitBJ(true, whichUnit) //the hook don't will run with this function since you can't detected the callback of the function

call PauseUnit(whichUnit, true) //the hook will run with this function since this is the direct function
 

Bribe

vJass errors are legion
Reaction score
67
Hooks in vJass are weak. A better programming language would allow the returned-value t be hooked, as well.

A compiled-hook in vJass turns into some ugly trigger evaluations, as well, instead of faster function-calls. Hooks are trash.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top