Page 1 of 1

Possible to make custom_input_prototypes read-write?

Posted: Mon Jul 06, 2020 8:29 pm
by jdogg
So I added a GUI with a button to read all the custom_input_prototypes and their key_sequence and it spits out a table with all the duplicates key sequences. I was wondering if it is even possible to allow a mod to write to the key sequence like you would do by going into the setting -> controls menu. The idea being that only duplicate mod custom inputs would be displayed and the player could change them directly from the mod GUI instead of finding them in controls menu. Unless I'm missing something in the API where this would already be doable.

https://mods.factorio.com/mod/project-corona - My Mod that does this

Re: Possible to make custom_input_prototypes read-write?

Posted: Tue Jul 07, 2020 10:54 am
by eradicator
LuaDoc wrote: LuaCustomInputPrototype.key_sequence :: string [Read-only]
The default key sequence for this custom input.
According to the doc that is not the current key sequence. The current key is probably not even part of the game-state.

Re: Possible to make custom_input_prototypes read-write?

Posted: Tue Jul 07, 2020 6:09 pm
by jdogg
Yeah I'd assume the same honestly, but I was hoping for a way to maybe access it on a per player basis since different players have different preferences of custom inputs.

Maybe something along the lines of:

Code: Select all

script.on_event(defines.events.on_gui_click, function(event)
    local player = game.get_player(event.player_index)
    player.active_input_prototype["custom-input-name"].key_sequence = "new-key-sequence"
end)