Hi everyone! I'm trying to create a simple Lua mod for BeamNG.drive that adds a custom keybinding. When you press the key, I want it to trigger a Lua function—for example, spawning a vehicle above the player. I already have a script and a FallingVehicle.lua file, but I'm not sure how to correctly set up the extensions.lua file and the input_actions.json for the keybinding to work in-game. Could anyone explain (or show an example of) how to: Create a basic extensions.lua that links to your custom script (at least I think that's what it does) Add a keybinding that runs your function Register the function in a way BeamNG will recognize it Any help would be awesome! Thanks!
I don't have a complete example, but adding a custom keybinding seems to be as simple as adding to your mod a file with a path like timo\lua\ge\extensions\core\input\actions\more_camera.json (where "timo" is the mod root folder and "more_camera" can be any name) with contents: Code: { "morecam_move_forward_backward":{"cat":"camera", "order": 37, "ctx": "tlua", "onChange":"if core_camera then core_camera.yAxisAbs(100*VALUE) end", "isCentered": true, "title": "Move camera (or seat) ahead / back", "desc": "Moves the camera or adjusts the driver seat forwards and backwards" }, "morecam_move_left_right" :{"cat":"camera", "order": 38, "ctx": "tlua", "onChange":"if core_camera then core_camera.moveLeftRight(0.5*VALUE) end", "isCentered": true, "title": "Move camera left / right (or tilt seat up / down)", "desc": "Moves the camera to the left or right, or tilts the driver seat up and down" }, "morecam_move_up_down" :{"cat":"camera", "order": 39, "ctx": "tlua", "onChange":"if core_camera then core_camera.movedown(VALUE < 0 and -0.5*VALUE or 0) core_camera.moveup(VALUE > 0 and 0.5*VALUE or 0) end", "isCentered": true, "title": "Move camera (or seat) up / down", "desc": "Moves the camera or adjusts the driver seat up and down" } } Then in my AppData\Local\BeamNG.drive\0.35\settings\inputmaps\mouse.diff I have these bindings: Code: { "action":"morecam_move_forward_backward", "control":"zaxis", "filterType":1 }, { "action":"morecam_move_left_right", "control":"xaxis", "deadzoneResting":0.95, "linearity":5 }, { "action":"morecam_move_up_down", "control":"yaxis", "deadzoneResting":0.95, "isInverted":true, "linearity":5 }, BTW, what all this does is it allows moving the camera in free mode forward/backward with the scroll wheel, as well as moving it horizontally and vertically by moving the mouse pointer to one of the edges of the screen.