1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice
  3. Before reporting issues or bugs, please check the up-to-date Bug Reporting Thread for the current version.
    0.35 Bug Reporting thread
    Solutions and more information may already be available.

How to make certain buttons momentary instead of toggle?

Discussion in 'Troubleshooting: Bugs, Questions and Support' started by Reece Coates, Feb 27, 2021.

  1. Reece Coates

    Reece Coates
    Expand Collapse

    Joined:
    Apr 3, 2020
    Messages:
    1,163
    Hey, I just wanted to know if there is a way to make certain buttons like maybe the range switch/4x4 button momentary instead of toggle so that they will only be on as long as I have a switch on. Like how the shifter buttons work, it's only in that gear as long as that button is pressed. If there isn't a way to do this would the devs consider adding an option in each control in the controls menu for this function in the next update?
    --- Post updated ---
    I ask this because my brother is currently building an Arduino-based button box for American Truck Simulator and Beam and it has a bunch of switches.
     
  2. NOCARGO

    NOCARGO
    Expand Collapse

    Joined:
    Apr 1, 2019
    Messages:
    1,470
    It takes a little effort but this can be perfectly achieved thru a custom input_actions.json file that you can place in your mods vehicle folder. The file input_actions.json is especially designed to put vehicle specific bindings in. The bindings can be set up in different ways.
    In your case :
    Code:
    "yourSwitch"      :{"order":  20, "onDown":"electrics.values.yourSwitch = 1-(electrics.values.yourSwitch or 0)", "onUp":"electrics.values.yourSwitch = 1-(electrics.values.yourSwitch or 0)", "title": "Your Switch", "desc": "Activates your switch" },
    Of course the nature of your feature should be properly defined in a lua file. In other words : electrics.values.and_so_on must be recognized before you can make it a switch. You can also put functions and other code in the input_actions.json. The code is a bit tricky but best is to learn from existing input_actions files. Also take notice of the number behind "order". If you have 5 bindings in your file you sort them from 1 to 5, that defines the order of appearance of the bindings in-game :)

    Another important thing is that the use of a custom input_action.json in a mod will overwrite vanilla input actions (and thus bindings). So to do this right you should copy the whole original vehicles file and then add your bindings to that file.

    Hope this helps.
     
  3. Reece Coates

    Reece Coates
    Expand Collapse

    Joined:
    Apr 3, 2020
    Messages:
    1,163
    Very helpful. I'll be sure to keep this in mind for when I finish my button box. In the meantime, it would be nice if the devs added a checkbox or something to the menu that switches the function of the button, whether it's toggle or momentary.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice