Hello all, I m making air suspension for all cars. And i've been asked and want to have independent controls front/back and possibly left/right. However i don't know how to do so in the custom_input.lua can anybody help? here's what i tried to do, but then nothing worked:
Hi, I just separated front and rear spring airbag input. I also removed some obsolete code (from the canon). I just modifed the files for the Grand Marshal. First I separated the inputSource for front and rear suspension hydros to lifter_F and lifter_R. Code: ["fh4r","fs1r",{"inputSource":"lifter_F","inLimit":-1.66,"outLimit":-1.66,"inRate":1,"outRate":1,"inputFactor":-1}], ["fh4l","fs1l",{"inputSource":"lifter_F","inLimit":-1.66,"outLimit":-1.66,"inRate":1,"outRate":1,"inputFactor":-1}], Code: ["axsshl","r1ll",{"inputSource":"lifter_R","inLimit":-1.99,"outLimit":-1.99,"inRate":1,"outRate":1.1,"inputFactor":-1}], ["axshr","r1rr",{"inputSource":"lifter_R","inLimit":-1.99,"outLimit":-1.99,"inRate":1,"outRate":1.1,"inputFactor":-1}], Addiotionally added input actions so you'll be able to trigger different code corresponding to the input. Code: { "liftUp_F" :{"order": 3, "onChange":"custom_input.liftBarrel('F', 0.5 * VALUE)", "title": "Lift Up Front", "desc": "Lifts the barrel up" }, "lowerDown_F":{"order": 4, "onChange":"custom_input.liftBarrel('F',-0.5 * VALUE)", "title": "Lower Down Front", "desc": "Lowers the barrel down" }, "liftUp_R" :{"order": 3, "onChange":"custom_input.liftBarrel('R', 0.5 * VALUE)", "title": "Lift Up Rear", "desc": "Lifts the barrel up" }, "lowerDown_R":{"order": 4, "onChange":"custom_input.liftBarrel('R',-0.5 * VALUE)", "title": "Lower Down Rear", "desc": "Lowers the barrel down" }, } Furthermore added more bindings for keyboards. Code: "bindings" : [ { "control" : "pagedown" , "action" : "liftUp_F" }, { "control" : "pageup" , "action" : "lowerDown_F" }, { "control" : "U" , "action" : "liftUp_R" }, { "control" : "J" , "action" : "lowerDown_R" }, ], Last but not least I modified the lua code. Code: local function onReset() electrics.values['lifter_F'] = 0 electrics.values['lifter_F_input'] = 0 electrics.values['lifter_R'] = 0 electrics.values['lifter_R_input'] = 0 electrics.values['shoot'] = 0 end local function updateGFX(dt) -- ms electrics.values['lifter_F'] = math.min(1, math.max(-0.0, (electrics.values['lifter_F'] + electrics.values['lifter_F_input'] * dt * 0.2))) electrics.values['lifter_R'] = math.min(1, math.max(-0.0, (electrics.values['lifter_R'] + electrics.values['lifter_R_input'] * dt * 0.2))) end local function liftBarrel(part, value) if part == "F" then electrics.values.lifter_F_input = value end if part == "R" then electrics.values.lifter_R_input = value end end Through the input actions I pass which suspension will be modified, so either 'F' or 'R'. In the end I just copy/pasted the calculation and modified it so it fits the requirements to either adjust the hydros of the fron or rear suspension. I'll add the zip. I used the last version of your mod from the repository as an entry point. Please take a look at the files and let me know if something is not clear enough. Also this should also work for left/right, you just need to add more actions, bindings, and th corresponding lua code.
Awesome! thank you for the help. I was lost on the lua code... I will get to making individual 4 channel AirSuspension with this But there is actually one more idea I had and need help with: can I utilise the same hydros to make the vehicle jump? If you saw the input actions file I attached above and found it crazy, here's the reason: it's because I was trying to do so(jump) with 'onDown' and 'onUp'... to have it lift very quickly when key is pressed and return quickly after the key is released, causing a "jump" and then the contrary for "slamming" lastly, a 'onChange' with a reduced multiplier remains to keep the adjustment controls... being the multiplier reduced here due to the fact that I increased the movement ratio on the jbeam hydros... all that for each suspension resulted in 24 controls. I did it all wrong didn't I?
It helps if you remove the shocks from the vehicle. They limit the speed at which the suspension moves.
I've studied auto mechanics and forgot to think about that... but I don't think that would completely prevent the jumping... with stock suspension it can lift and lower quite quickly enough for when the car encounters bumps and dips on roads... force the vehicle down with node grabbing and when you release it almost jumps... also, if possible, it'd be nice not to ruin the vehicles' driving while doing it.