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?