It seems like lua triggers only execute code under the ge lua rather than the vehicle lua.. Is there any workaround to access v.lua from these triggers? Any help is appreciated.
I'd like to place the lua trigger at a gas station so that when I pull up to the pump it will fill up the gas tank
Could you set global variable that vehicle lua would then read and based on it's value do fillup? Of course it would be more efficient if you could just trigger and then run action only once, but if not possible, that might maybe work? I'm not really competent with Lua though, so even my idea might not work at all.
Hmm.. well I did some more digging and found that you can execute vehicle lua in GE lua like this as an example: Code: be:getPlayerVehicle(0):queueLuaCommand("obj:queueGameEngineLua('print('..electrics.values['fuelVolume']..')')") But I can't seem to be able to set a fuel amount using the same method, I try the following and it doesn't work: Code: be:getPlayerVehicle(0):queueLuaCommand("obj:queueGameEngineLua('energyStorage.getStorage('mainTank'):setRemainingVolume(2)')") I need to know how to write to vehicle lua from GE lua.
Why are you sending the code you want to be executed first from GE to vehicle Lua and then back to GE? You just need the first queueing, not the second one.
I thought I had to do it this way, I was looking at post #2 of this article to see how to do it: https://www.beamng.com/threads/a-way-to-get-a-value-from-system-lua-t3d-lua-gameengine-lua.25139/ Sorry, not sure exactly what you mean by this.. I'm testing it in ge lua in the console and no matter how I type it, I can't get it to set the fuel amount.
Hm sorry, didn't get notified about your first answer. Try this: Code: be:getPlayerVehicle(0):queueLuaCommand("energyStorage.getStorage('mainTank'):setRemainingVolume(2)")