Hello all. First post here, newbie to LUA and JBEAM. I'm trying to make self-adjusting nitrous shots based on vehicle speed. Basically I want the nitrous to increase as vehicle speed increases. I have successfully made a helloworld.lua that gives me wheelspeed data and stores it to 'testvar' This LUA file was placed in the lua folder inside of the vehicle directory. Code: local M = {} local function updateGFX(dt) testvar = electrics.values.wheelspeed print(testvar) end M.updateGFX = updateGFX return M When playing Beamng I can open the console and see a constant stream of values for testvar so I know its got the right data. Here's my code on the nitrous side. n2o.jbeam Code: "n2o_shot_variable": { "information":{ "authors":"BeamNG", "name":"Adjustable Shot Size", "value":200, }, "slotType" : "n2o_shot", "variables": [ ["name", "type", "unit", "category", "default", "min", "max", "title", "description"], ["$n2o_power", "range", "kW", "Nitrous Oxide", 75, 25, 1900, "Added Power", "Power increase the N2O injection grants", {"stepDis":5}], ], "n2o": { "addedPower": "$=$testvar*50", }, }, } It seems like 'testvar' is not being read properly in n2o.jbeam, as when I hit the nitrous it does nothing. Like it's set to 0. If I replace "$=$testvar*50" with an integer it'll activate the nitrous. So I know the JBEAM is working. Any idea what I'm missing here? Thanks
Sadly it's not possible to just pass variables freely like this. You would have to create a custom version of the N2O controller and do the setup there.
Kinda figured I was barking up the wrong tree. I think I'll be able to accomplish the same thing by editing Beamng's included nitrousOxideInjection.lua now that you mentioned that method. Thanks!
For anyone curious, this is possible by changing one line in nitrousOxideInjection.lua Change Code: assignedEngine.nitrousOxideTorque = assignedEngine.nitrousOxideTorque + noTorque To: Code: assignedEngine.nitrousOxideTorque = (assignedEngine.nitrousOxideTorque + noTorque) * (1 + ((electrics.values.airspeed ^ 1.36) / 16.5)) Have your adjustable nitrous shot in game set to whatever your car can handle out of the hole. In my case this was right around a 50 shot. Replace the exponent 1.36 with a higher number for more nitrous on the big end. Replace 16.5 with a lower number to give more nitrous throughout the entire run. This makes nitrous SO much more fun. For example I took a 15 sec 4 door sedan into the mid 9s on an unprepped road. Nitrous starts at a 50 shot out of the hole but by the eighth mile it's spraying around a 1000hp shot. This comes close to emulating a nitrous controller that has the ability to ramp in more nitrous as vehicle speed increases.