Hey, I have some problems with the lua triggers and lua commands. I am trying to make a working gas station, so you can drive up to the pumps and then it refuels and we can keep going with full tank. But I am getting some "returned nil value" errors. I have looked thru the wiki and searched for help but can not find anything that helps me. If you need any pictures of the setup or any code, let me know.
Are the Lua triggers in the GE Lua (Game Engine Lua) instead of the Vehicle Lua? If so you'll need to pass values back and forth and it could get tricky. Take a look here: http://www.beamng.com/threads/a-way-to-get-a-value-from-system-lua-t3d-lua-gameengine-lua.25139/ --- Post updated --- So it turns out that the triggers are using hooks, which is good. I think that your code should look something like this: Code: local M = {} local function onBeamNGTrigger(data) if data.event == "your_trigger_name_here" then -- this is where we might fill the gas tank print("Gas tank filled!") end end M.onBeamNGTrigger = onBeamNGTrigger return M
Thank you for replying, but this didnt work. I used the code you sent and got this error: http://prntscr.com/cxk2ka in the console.
I have't added any lua file but I have added the code straight in the worldeditor like this: http://prntscr.com/cxxjw5
The trigger, when properly setup, should generate a hook. This hook should work similarly to onRaceWaypoint(whatever) for example. Take a look at heavy_cargo_v2.lua in The Gas Station's Heavy Delivery Pack:Utah scenario pack for an example of how to use a hook like that in a scenario lua. These are all of the hooks used in that Lua: onScenarioRestarted, OnScenarioLoaded, onRaceTick, onRaceWaypoint, onRaceStart, onScenarioChange. You can see where all of those are defined at the bottom of the file. Scenario lua files run inside the GE Lua.