Just wanted to suggest maybe add thrusters/boosters to make your car go super fast, It will be awesome to see your car do flips over obstacles
If found a thrust setting for lua but have no clue how to implement. or if I am even able to implement it. I would be interested in this function. the thruster file in lua folder: Code: [COLOR=#666666]-- This Source Code Form is subject to the terms of the bCDDL, v. 1.1.-- If a copy of the bCDDL was not distributed with this[/COLOR]-- file, You can obtain one at http://beamng.com/bCDDL-1.1.txt local M = {} M.activeThrusters = {} local thrusterState = {} local autoThrusters = {} local thrusting = false local gfxFrameTick = 0 local function nop() end local function update() -- node1 is source, node2 is destination -- we apply and measure forces/velocity for node2 local t for key, thruster in pairs(autoThrusters) do local vel = -obj:getNodeVelocity(thruster.id2, thruster.id1) if vel > 0.3 then t = (vel *vel) * thruster.factor if thrusting then t = math.min( math.max(obj:getNodeForce(thruster.id1, thruster.id2), 0) + t, thruster.thrustLimit) else t = math.min( t, thruster.thrustLimit) end obj:applyForce(thruster.id2, thruster.id1, t ) if gfxFrameTick == 1 then obj:addParticleByNodesRelative(thruster.id2, thruster.id1, -37 , 3, 0.1, 1) obj:addParticleByNodesRelative(thruster.id2, thruster.id1, -44 , 3, 0.1, 1) end end end for key, thruster in pairs(thrusterState) do -- applyForce(node1, node2, forceMagnitude) obj:applyForce(thruster[2], thruster[1], thruster[3]) if gfxFrameTick == 1 then obj:addParticleByNodesRelative(thruster[2], thruster[1], -37, 3, 0.1, 1) obj:addParticleByNodesRelative(thruster[2], thruster[1], -44, 3, 0.1, 1) end end if gfxFrameTick == 1 then gfxFrameTick = 0 end end local function updateGFX() thrusterState = {} for key, thruster in pairs (M.activeThrusters) do if thruster.control == '+axisX' and input.axisX > 0 then table.insert(thrusterState, {thruster.id1, thruster.id2, math.min(input.axisX * thruster.factor, thruster.thrustLimit)}) elseif thruster.control == '-axisX' and input.axisX < 0 then table.insert(thrusterState, {thruster.id1, thruster.id2, math.min(-input.axisX * thruster.factor, thruster.thrustLimit)}) elseif thruster.control == '+axisY' and input.axisY > 0 then table.insert(thrusterState, {thruster.id1, thruster.id2, math.min(input.axisY * thruster.factor, thruster.thrustLimit)}) elseif thruster.control == '-axisY' and input.axisY < 0 then table.insert(thrusterState, {thruster.id1, thruster.id2, math.min(-input.axisY * thruster.factor, thruster.thrustLimit)}) elseif input.keys[thruster.control] then table.insert(thrusterState, {thruster.id1, thruster.id2, thruster.thrustLimit}) end end thrusting = (next(thrusterState) ~= nil) gfxFrameTick = 1 end local function init() -- update public interface if v.data.thrusters == nil or next(v.data.thrusters) == nil then M.update = nop M.updateGFX = nop return else M.update = update M.updateGFX = updateGFX end thrusterState = {} autoThrusters = {} M.activeThrusters = {} for key, thruster in pairs(v.data.thrusters) do if thruster.control == 'auto' then table.insert(autoThrusters, thruster) else table.insert(M.activeThrusters, thruster) end end for key, thruster in pairs (M.activeThrusters) do thruster.factor = thruster.factor or 1 thruster.thrustLimit = thruster.thrustLimit or math.huge end end local function reset() init() end -- public interface M.reset = reset M.init = init M.update = nop M.updateGFX = nop [COLOR=#666666]return M [/COLOR]
I got it working lately Code: "thrusters": [ ["id1:", "id2:"], {"factor": 10000}, {"thrustLimit": 10000}, {"control": "H"}, ["thruster", "thrusterbase"], {"factor":10}, {"thrustLimit":20000}, {"control": "G"}, ["thrusterbase", "thruster"], ], It works similar to beams. Code: ["id1:", "id2:"] The first id is what the node which force is applied to is called, and the second is the node defining the direction of the force Putting things in braces is like the options/configuration of the thrusters. What "factor" and "thrustLimit" are, is that they work in this idea: thrustToApply = max( thrustToApply + factor, thrustLimit ), basically the thrust increases by "factor" everytime until it reaches "thrustLimit" (make both the same number for no spin-up time) In my example above I created two thrusters working in opposite directions, controlled by H and G keys. The first thruster is insta-spin-up, doesn't require time to apply a great force, while the second requires a little bit of time (I'm not sure exactly, but I'm assuming it's based on 20*millisecond, giving 2 seconds to full thrust) Few tips: The "control" can also be "+axisX", "-axisX", "+axisY", "-axisY", I haven't tested if every key works but for ones that do work use the uppercase letter. You could also write the definition as: ["id1:", "id2:", "factor", "thrustLimit", "control"] if you don't want to use braces for the options, so you get this: Code: "thrusters": [ ["id1:", "id2:", "factor", "thrustLimit", "control"], ["thruster", "thrusterbase", 10000, 10000, "H"], ["thrusterbase", "thruster", 10, 20000, "G"], ], I'm assuming that this is all unsupported and may be prone to change, anyhow I had quite some fun with it
I made a tutorial in the programming section. http://www.beamng.com/threads/5250-...S-to-cars-via-LUA-Scripting?p=60349#post60349