How to substitute an exposed vehicle controller function?

Discussion in 'Programming' started by SineMatic, Jul 9, 2025 at 9:02 PM.

  1. SineMatic

    SineMatic
    Expand Collapse

    Joined:
    Nov 17, 2022
    Messages:
    62
    So here's my problem. I've made a jbeam part that uses a custom controller with the path: \lua\vehicle\controller\. Inside the controller file there's a line of code:
    Code:
    M.update = nop
    When I try to substitute this function like this:
    Code:
    local function updateModified(dt)
      print("hi")
    end
    M.update = updateModified
    or like this:
    Code:
    controller.getControllerSafe("controllerName").update = function(dt) print("hi") end
    , nothing happens. The first way works for other lua modules though.
    Am I missing something? Any help appreciated!
     
  2. SineMatic

    SineMatic
    Expand Collapse

    Joined:
    Nov 17, 2022
    Messages:
    62
    Quick update. Probably I'll just use boolean flags and if-statements.

    By the way, I've also found another workaround to the problem:
    Code:
    local function testFunction(dt)
      print("hi")
    end
    
    local function update(dt)
      M.intermediateFunction(dt)
    end
    
    M.update = update
    M.intermediateFunction = nop
    After running
    Code:
    M.intermediateFunction = testFunction
    the module starts printing the word.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice