|Tim Derks (timmiej93)||31.10.2019 17:32|
|I want to dynamically add a keybinding in code, instead of adding it through the ModDesc file. I want to experiment with adding a GUI to all my mods, containing some info and settings, if applicable. I don't want to clutter the already limited keyboard with a different combination for opening that GUI for each mod though, and I also would prefer not to see multiple entries in the keybindings menu. I doubt there's a way to do this through the ModDesc, so I'm looking for a lua alternative.
I've done some research and found the "InputAction.addBinding" function, but without documentation, it's almost impossible to find out what arguments the function requires, and what it even does.
Does anyone know more about this?
|Gtx | Andy (GtX_Andy)||04.11.2019 08:32|
You will need to be a little more descriptive. Are these placeable mods, vehicle mods or anytime mods not relating to either? :-)
|Tim Derks (timmiej93)||04.11.2019 13:43|
|Like I said in my initial post: The keybinding I want to add will be used to open a GUI. Since this has to be done in lua code, surely it doesn't really matter what kind of mod It'll be used on, right? I would say code will run on anything.
|Gtx | Andy (GtX_Andy)||05.11.2019 10:30|
|I think it would have been a shorter post for you just to answer the question. Of course it makes a difference as I would not have asked otherwise. The reason I asked is to know how to structure the answer so you do not have keybinding conflicts.
If it is a placeable for example you could use the 'activatableObject' feature but without real info on the use (vehicle, placeable or player (in vehicle), player (out of vehicle) or player (anytime)) no one can give you the correct answer on the best way to do as you wish with.
To add a keyBinding this needs to be done different to previous version of FS. You should not be using the `update loop` for example to listen for an input.
|Tim Derks (timmiej93)||05.11.2019 15:02|
|I'm very well aware of how keybindings work in FS19, but I'm thinking you're not getting what I'm trying to do.
I'm not just trying to open a GUI for one mod (like for your Easy Development Tools for example), I'm trying to open the _same_ GUI for multiple mods. I have already created a system where every mod of mine has a GUI, with 1 page with general information about my mods and about the GUI they just opened, and 1 or multiple pages with information about each mod of mine that's running in that savegame. So no matter what combination of my mods is enabled on a savegame, the GUI will always show: 1x the main page/tab, and then at least 1 page/tab for each of my mods, all in the same GUI.
I know I can add a keybinding to each mod, with the same name, and the same keybinding, and it will work in most cases. However, this creates issues in the keybinding's settings screen, since it'll say "T93 Open Mods Menu" as many times as you've got a mod of mine installed. Especially when trying to re-bind this action, that can get very annoying. I also can't only put the open-menu-binding in one of the mods, since I don't know what combination of my mods people would want to use. The experience has to be the same, regardless if they installed 1 of my mods, or all of them. I _really_ doubt this is achievable through any of the normal methods , which is why I need to add it in code.
I'm not trying to act upon the keypress, I'm just trying to register the keybinding in the game, which you'd normally do by adding an action and an actionbinding in the modDesc."
I hope you now understand that my situation isn't as clear cut, and that I can't answer the question on what kinds of mods this applies to, because it can apply to literally anything, and is therefore irrelevant.
|Gtx | Andy (GtX_Andy)||09.11.2019 11:06|
|Well you can just use one of Giants keybindings if you wanted but it will be hard to find one that does not conflict for every situations. This was the reason I asked I did not mean to offend at all :-).
This method may work if you did not mind having something different for so vehicle mods vs placeable mods where the player is not entered and seen as a vehicle.
Did you want the input displayed in the `help / F1 Menu`? If not maybe the old system of using the 'keyEvent' function and sym or unicode numbers.
I am more than happy to help find a solution though I am sure we can ;-)
Note: Log in to post. Create a new account here.