Mod hotkeys: custom-input documentation please?

Place to get help with not working mods / modding interface.
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Mod hotkeys: custom-input documentation please?

Post 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?
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Mod hotkeys: custom-input documentation please?

Post 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?
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
User avatar
mickael9
Fast Inserter
Fast Inserter
Posts: 112
Joined: Mon Mar 14, 2016 4:04 am
Contact:

Re: Mod hotkeys: custom-input documentation please?

Post by mickael9 »

Can we pin this thread please?
Rseding91
Factorio Staff
Factorio Staff
Posts: 14596
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Mod hotkeys: custom-input documentation please?

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Zaflis
Filter Inserter
Filter Inserter
Posts: 519
Joined: Sun Apr 24, 2016 12:51 am
Contact:

Re: Mod hotkeys: custom-input documentation please?

Post 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.
Post Reply

Return to “Modding help”