I'm writing a transmission extension using an input mapping to select differential modes and lockings. I'd like to use the same input mapping for all vehicles, using a custom lua file for the actions code. The reason for using the same mapping for all vehicles is that it will avoid to have to redo the bindings for each different car, and to avoid the files duplication hassle. Then i tried to put the input_actions.json file in this mod path : mods\unpacked\advanced_transmission\lua\ge\extensions\core\input\actions But i'd like to use a custom_input.lua file for easier modes management. then if using this kind of command in the input_actions.json : onUp: "custom_lua_file.set(VALUE)" Then it does not work, i get an error when the extension is loaded regardless where i try to put the custom_lua_file : How can i use the same input action mapping for all vehicles, using a custom lua file ? Perhaps it is simply a path problem ? I did not find in the documentation where we should put the custom lua file in the mod folder structure in this case. As a side note, It works if i'm using electricals signals commands directly in the input_actions.json file or If i'm using a vehicle path in the mod for the input_actions.json file, then it's working, i do not get this error. I did check how a custom lua file is called in the game from the "BeamNG.drive\lua\ge\extensions\core\input\actions" folder, we have that for example for camera.json : "bigMapZoom":{"cat":"camera", "order": 121, "ctx": "tlua", "onChange":"if freeroam_bigMapMode then freeroam_bigMapMode.zoom(VALUE) end" Then it should be possible to use that in a mod as well ? I tried using "ctx": "bvlua" '“bvlua” (according to the documentation it is for all vehicles - lua (async)). But again it was not working. Thanks for helping.
I see no takers still. I started getting into LUA and made a small throttle and brake control system yesterday. But just like you said I have to add it as a slot to each car I want to use it on. I'd like to make it universal for every vehicle automatically. But seeing as how there's so many mods out there that still have to copy every car's jbeam file, I don't think there's any answer yet. If there is an answer, then someone is holding it close to their chest. I did see a mod that used LUA to copy, rename, and then modify jbeam files automatically. It was rather complex. The code to do that was way more than the code for core the mod itself.
Hopefully we'll have an answer for that. Duplicating files to adapt an extension to different cars is very time consuming an more importantly updating extensions with duplicated files for each car become so long that it becomes a serious brake to extension updates.
For the inputs you might have to set the "ctx" parameter to "vlua"(Vehicle lua for only the active vehicle) As for the lua code to get it functioning in all vehicles you might want to store it as a controller and then call upon it in the jbeam for each vehicle you use it in. This is a example of roughly how some custom transmission code of mine is setup lua/vehicle/controller/eaton_controller.lua local M = {} M.type = "auxiliary" local function toggleRange() if rangeBox then if rangeSelect == "low" then rangeSelect = "high" else rangeSelect = "low" end end end M.toggleRange = toggleRange return M lua/ge/extensions/core/input/actions/input_actions_efc_eaton.json { "toggleRangeStatusRR":{ "cat":"vehicle", "order": 171, "ctx": "vlua", "onDown":"controller.getControllerSafe('eaton_controller').toggleRange()", "title": "(EFC)RoadRanger: Range Toggle", "desc": "Toggles Range-box gears on the Road-Ranger." }, } vehicles/us_semi/us_semi_transmission_eaton.jbeam "controller": [ ["fileName"], ["eaton_controller", {}], ],
Thanks a lot this is very informative. Someone needs to write a book chapter about the folder structures inside the mod folder, and the possibilities. Some things are still confusing for me, specially the common folder and i did not find much information about it.
The common folder is a special folder in BeamNG which allows sharing of vehicle textures, models and parts. Normally when you add stuff to a specific vehicle folder(ex: covet). The stuff can only be used/accessed by that one vehicle. Putting stuff in the common folder allows ANY vehicle to access it. This is useful for 1. Fairly universal parts such as wheels/tires 2. For vehicles based on a shared platform like the Gavril D-series, H-series and Roamer.
@epicfacecanada Thanks for this. Is there any current documentation anywhere that lists all of these functions like 'onDown' that we can call for controller/keyboard input commands? As it is now, I'm just dissecting other people's mods and finding them out. It's like this stuff is only learned by word of mouth and there's no full API published that I know of.
Here: https://documentation.beamng.com/modding/input/ --- Post updated --- By the way, now “input_actions.json” is gradually being replaced by “*.interaction.json” This is the same thing, but with the ability to disable bindings that are not used, for example, depending on whether the part is installed or not. Very useful for controllers (I don't know why it's not in the “input” section) https://documentation.beamng.com/modding/vehicle/sections/triggers/triggers2/#interaction-maps
I tried doing what you posted to do what I wanted to do, but for some reason I couldn't get it to work. But I was hacking around and figured out how to do what I wanted to do. I simply wanted to map these two commands to a controller button at the same time: extensions.gameplay_forceField.toggleActive() extensions.gameplay_forceField.setForceMultiplier(10) I found the gameplay.json file where it sets up this binding to map to: "forceField" :{"cat":"gameplay", "order": 46, "ctx": "tlua", "onDown":"extensions.gameplay_forceField.toggleActive()", "title": "ui.inputActions.gameplay.forceField.title", "desc": "ui.radialmenu2.funstuff.ForceField.desc"}, And I simply added the setForceMultiplier(10) command: "forceField" :{"cat":"gameplay", "order": 46, "ctx": "tlua", "onDown":"extensions.gameplay_forceField.toggleActive()extensions.gameplay_forceField.setForceMultiplier(10)", "title": "ui.inputActions.gameplay.forceField.title", "desc": "ui.radialmenu2.funstuff.ForceField.desc"}, You don't even have to put a space in between the commands. The game engine will execute them in order. I set the multiplier to 3 when I want to see the carnage up close and personal, and I set it to 10 when I want to drive 160mph and still repel traffic cars head on without crashing into them. You then just put the edited gameplay.json file into a folder structure like this and add it to a .zip file: \lua\ge\extensions\core\input\actions\gameplay.json Drop it into the repo folder and voila! I might get fancy later and allow the multiplier value to be changed via jbeam or UI app, but for now it's exactly what I wanted.