.lua call function on initialisation of vehicle

Discussion in 'Programming' started by VertexStyle, Feb 17, 2018.

  1. VertexStyle

    VertexStyle
    Expand Collapse

    Joined:
    Dec 11, 2016
    Messages:
    180
    Programmed a vehicle .lua function. With a keyboard binding it works just fine.
    However I want the function to start running as soon as the car is spawned.
    How can I do that? I thought init() / onInit() would do exactly that but for some reason it doesn't work?


    Ending of the .lua script:

    local function init()
    regenEnabled = true
    M.regenerate()

    -- run this code when the vehicle is loaded?!?
    end


    -- public interface
    M.regenerate = regenerate
    M.cancelRegenerate = cancelRegenerate
    M.onReset = onReset
    M.updateGFX = updateGFX
    M.sendState = sendState
    M.init = init

    return M
     
  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