Flexibility of mod input actions and translation text

Discussion in 'Content Creation' started by Arcanox, Oct 5, 2021.

  1. Arcanox

    Arcanox
    Expand Collapse

    Joined:
    Aug 22, 2018
    Messages:
    300
    This is kind of a two-in-one...suggestion, I guess? I am unable to find anything in the existing Lua code that suggests that either of these are already possible, but if there's a way, I'm all ears!

    As I posted in another thread recently, I'm currently in the middle of a huge overhaul of my Hybrid mods. One of the things I'm trying to do is to make my hybrid system more modular/portable so that it's easier for people to adapt it to other vehicles. One of the recent changes I made is to move the "input_actions" definitions I had in each of my hybrid vehicles to a central/global input_actions file in my Core mod, and I'm using an ActionMap to conditionally enable these actions if the player's active vehicle has a Hybrid controller present. This part works great.

    The part(s) I'm having troubles with involve default bindings and UI text. I can't ship default bindings for the input actions anymore, because there appears to be no way to specify a "partial" default bindings file. I was already running into issues with the Citybus, because my "vehicles/citybus/inputmaps/keyboard.json" file would remove the default bindings for things like "Toggle Doors", "Toggle Kneel", etc. The fact that the mod's "keyboard.json" file is present made the game totally ignore the one in the base game content files. That wasn't the end of the world or anything, but it was annoying that players who utilized the default bus bindings (myself included...) would lose them and have to manually reset them after installing my mod. And, of course, it was a non-issue with the ETK800 because that vehicle doesn't have vehicle-specific bindings by default.

    Now that I've made my input actions global, however, the problem becomes a bit more annoying. If I ship a "settings/inputmaps/keyboard.json" file with my mod, it will overwrite the base game's and remove every single default binding in the game, which obviously makes that a no-go. I can rename it to "settings/inputmaps/keyboard.diff", but if a player has already customized any controls for the keyboard previously, it won't have any effect and they won't get any default bindings for my actions.

    The second part here is somewhat related, and I'll explain how so at the end here. While I was moving my input actions around, I thought "Gee, wouldn't it be nice to use translation keys in my input_actions file and include a default English locale, so that other players can create translations for my Hybrid-related strings?". I changed the "title" and "desc" of my actions to translation keys, and put a "locales/en-US.json" file in my mod. I was thrilled to see it just work and translate my action text...for a half a second, that is, until I realized that only my action text was translated, and the entire rest of the game's UI was all just translation keys (sidenote: the "Flowgraph Editor" control category doesn't use a translation key at the moment ;)).

    The reason I say these two issues are related is because they both seem to stem from the inability for mods to merge in additional content, at least in these two regards. It would be nice if I could include default input bindings in my mod without overwriting all the base game's input bindings, and likewise, it would be nice if I could include some additional translation keys in my mod for the English language, and if others could distribute additional translation keys in their own mods to add community translations for other mods.

    I didn't dig far enough to see if the game's filesystem layer already supports "merging" or "enumerating" files with the same relative path instead of "overwriting", but I'd guess something similar to the existing "input_actions_suffix.json" method could be used for inputmaps and for locales, so I could ship "settings/inputmaps/keyboard_arcanox_core.json" for my "lua/ge/extensions/core/input/actions/arcanox_core.json" actions, and a "locales/en-US_arcanox_core.json" file to add additional translation keys for text in my mod.
     
    • Like Like x 2
    • Agree Agree x 1
  2. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,665
    Years ago something like this would work, the game would merge the files instead of overriding them. I have no idea what changed and when, but it doesn't work anymore. It would be cool if it worked again.
     
  3. Arcanox

    Arcanox
    Expand Collapse

    Joined:
    Aug 22, 2018
    Messages:
    300
    I just stumbled across another somewhat strange instance of (what I think is) the same root problem. I discovered that the mod manager looks for a "modScript.lua" file in the "scripts" folder of all installed mods so that it can execute the script when the mod loads. However, if multiple mods include one, only the first mod's script (alphabetically) will be executed. In this particular situation, it searches recursively, so you can put "modScript.lua" in a unique subfolder inside "scripts", but there's nothing enforcing that anywhere. I'm guessing that, at some point, the "FS:findFiles" function might have returned all matching files, even if multiple mods included files with the same "relative path". That's just a guess. If that was the case, that would explain why these files used to be merged, as @Agent_Y mentioned.
     
  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