Thread: Functions overriden twice
-
September 21st, 2022, 17:47 #1
- Join Date
- Aug 2020
- Posts
- 94
Functions overriden twice
Hi I am trying to correclty save old references and call them in overridden functions however I get some sort of recursion:
Code:function onInit() -- save the old ref oldRef = SomeModule.SomeFunction; -- replace the function reference with new code SomeModule.SomeFunction= new_function; end function new_function() Debug.chat("1") oldRef() end
whenever SomeModule.SomeFunction gets called I get "1" twice in the chat (and the function is executed twice)
however if I "hard" override the function e.g.
Code:function onInit() -- replace the function reference with new code SomeModule.SomeFunction= new_function; end function new_function() Debug.chat("1") -- <just copy paste the old code here> end
I only get "1" once in the chat and the function in only executed once.
What could this be?Last edited by xelab; September 21st, 2022 at 19:51.
-
September 21st, 2022, 20:02 #2
- Join Date
- Aug 2020
- Posts
- 94
Sorry to have bothered, I have figured it out. My script was sourced in two places, in extension.xml, and in another .xml file, that is onInit was called twice leading to this recursive behavior.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks