Page 1 of 1

Mod hotkeys: custom-input documentation please?

Posted: Sun Aug 07, 2016 9:27 pm
by Qon
Where can I find documentation on mod hotkeys? I haven't found anything in wiki or api documentation so far. It's a nice feature, but shrouded in fog of war at the moment. ;)
Example data.lua:

Code: Select all

data:extend({
  {
    type = "custom-input",
    name = "handyhands-increase",
    key_sequence = "ALT + Q",
    consuming = "all"
  },{
    type = "custom-input",
    name = "handyhands-decrease",
    key_sequence = "mouse-button-2",
  }
})
What are the possible values and behaviours for "consuming"?
How do I translate a key_sequence to a text string, for any key sequence possible?
Are there other keys I should be aware of exept name and type that I can use?
Is it possible to detect key release/hold status?
What keys does the event object contain? player_index and something else?
Anything else I should know?

Re: Mod hotkeys: custom-input documentation please?

Posted: Sun Aug 07, 2016 9:59 pm
by Supercheese
Here's something I received a while back, from IRC IIRC: http://pastebin.com/raw/k44Ed5Gz

Re: Mod hotkeys: custom-input documentation please?

Posted: Sun Aug 07, 2016 10:12 pm
by Qon
Supercheese wrote:Here's something I received a while back, from IRC IIRC:

Code: Select all

Prototype definition:

data:extend({
{
  type = "custom-input",
  name = "my-custom-input",
  key_sequence = "SHIFT + R",
  
  -- 'consuming'
  -- available options:
  -- none: default if not defined
  -- game-only: The opposite of script-only: blocks game inputs using the same key sequence but lets other custom inputs using the same key sequence fire.
}})

Local definition:

[controls]
my-custom-input=Potato controls

Subscribing to the event:

script.on_event("my-custom-input", function(event) game.players.print("Ran on tick: " .. tostring(event.tick)) end)
Thanks. That reveals a bit about consuming at least. But which input event listener is going to get called first though? And what happens if "consuming: all" input is fired inbetween 2 "none" input listeners?

Re: Mod hotkeys: custom-input documentation please?

Posted: Sun Jun 11, 2017 10:08 pm
by mickael9
Can we pin this thread please?

Re: Mod hotkeys: custom-input documentation please?

Posted: Mon Jun 12, 2017 7:29 am
by Rseding91
All events are fired according to the mod sort order: http://lua-api.factorio.com/latest/Data-Lifecycle.html which is also effected by dependencies.

Re: Mod hotkeys: custom-input documentation please?

Posted: Thu Apr 30, 2020 3:22 pm
by Zaflis
For people stumbling on this thread in 2020, consuming = "script-only" is deprecated way to code. Your only options are
"game-only" or "none" https://wiki.factorio.com/Types/ConsumingType
Recommended choice is "none" that should work best for most mods.