Page 1 of 1

changing func to different func in middle of execution safe?

Posted: Thu Jun 15, 2017 4:35 pm
by Bugala
I am asking about Hollywoods innerworks about how this works to know if i can do this way.

I tried these two and they seem to work fine, but question is, is this safe thing to do or should i make temporal copy of the function that gets replaced or something to make sure it works right?

Code: Select all

Function customfunc_1()
  functable.func = customfunc_2
  DebugPrint("func_1")
EndFunction

Function customfunc_2()
  DebugPrint("func_2")
EndFunction


functable = {}
functable.func = customfunc_1

functable.func()
results in "Func_1" being printed as it should (notice that functable.func that is being executed is being replaced with func_2 before debugprint in customfunction_1 is executed)


Another test:

Code: Select all

Function customfunc_1()
  subfunc()
  DebugPrint("func_1")
EndFunction

Function customfunc_2()
  DebugPrint("func_2")
EndFunction

Function subfunc()
   functable.func = customfunc_2
EndFunction

functable = {}
functable.func = customfunc_1

functable.func()
Almost same as last one, but this time I am using subfunc to do the changing of the function. What worries me is that customfunc_1 jumps to subfunc, which replaces functable.func (that is right at that moment being executed) into customfunc_2 and after this is done, it returns from subfunc back to functable.func, but does it always return to the customfunc_1 execution (that have already been replaced) or might it in some case return to the new function.func, which would now be customfunc_2, and would it even know where there to return to?

Re: changing func to different func in middle of execution s

Posted: Fri Jun 16, 2017 11:06 am
by airsoftsoftwair
Sure, this is safe. You don't have to worry about that, once you jump into a function the VM will take care of everything else.

Re: changing func to different func in middle of execution s

Posted: Fri Jun 16, 2017 2:02 pm
by Bugala
Good. Didnt dare to start using those before getting confirmation from you, or it might have meant that when new Hollywood version would hit the street, it could suddenly stop working.