Unsolved How to create custom handler for light state change

Discussion in 'Mod Support' started by alexpixtunes, Aug 17, 2021.

  1. alexpixtunes

    alexpixtunes
    Expand Collapse

    Joined:
    Aug 17, 2021
    Messages:
    1
    Hi everyone,
    I want to trigger sending a UDP message (to trigger an action in a different application) when the car's light state is set to highbeams. I could just go into electrics.lua and send the message from there, but afaik this code change would be gone the next time I update the core code, right?

    I was wondering: What would be the best practice to add my custom code?

    The cleanest solution I could come up with (heads up, didn't work) was to create a custom extension under /lua/ge/extensions, register it in Steam's launch options (-lua registerCoreModule("mymodulename")) and override the toggle_headlights action in vehicle.json to call mymodulename.toggle_lights(), which would send my UDP message and then call the original electrics.toggle_lights.

    My implementation didn't work because the my extension module doesn't seem to end up in the global scope, the extensions module, or extensions.luaMods (tried all of them). Am I doing something inherently wrong? Should I be using the mods folder somehow?

    Thank you in advance guys, would really appreciate any input.

    Alex
     
  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