Starfinder Playlist
  1. #1

    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.

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in