Prototype/CustomInput: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(→‎linked_game_control: added list of control names, fixed name in example)
(there are no item ghosts)
 
(22 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== Basics ==
{{Prototype parent|PrototypeBase}}
Used for custom keyboard shortcuts/keybindings in mods.
Used for custom keyboard shortcuts/keybindings in mods. The key associated with the custom input can be changed in the options. This means that <code>key_sequence</code> is simply the default keybinding.
== Properties ==
 
Inherits all properties from [[Prototype]].
{{Prototype TOC|custom-input}}
 
== Mandatory properties ==
Inherits all properties from [[PrototypeBase]].


=== name ===
=== name ===
:''See [[Prototype#name]]''
:''See [[PrototypeBase#name]]''


Inherited from [[Prototype]]. It is also the name for the event that is raised when they key (combination) is pressed, see [[Tutorial:Script interfaces]].
Inherited from [[PrototypeBase]]. It is also the name for the event that is raised when they key (combination) is pressed and action is "lua", see [[Tutorial:Script interfaces]].


=== key_sequence ===
{{Prototype property|key_sequence|[[Types/string|string]]}}
'''Type''': [[Types/string]]
The default key sequence for this custom input.


The default key sequence for this custom input.
* "" (empty string) for unassigned
* "mouse-button-2" etc for mouse buttons, mouse-button-3 for middle mouse button
* "mouse-wheel-up", "mouse-wheel-down", "mouse-wheel-left", "mouse-wheel-right" for mouse wheel
* " + " is used to separate modifier keys from normal keys: <code>"ALT + G"</code>
* For modifier keys, the following names are used: "CONTROL", "SHIFT", "ALT", "COMMAND"
* A keybinding can contain an unlimited amount of modifier keys (listed above) but only one normal key (listed below).


* " + " is used to seperate two keys: <code>"ALT + G"</code>
<div class="toccolours mw-collapsible mw-collapsed" style="width: 40em;">
* "CONTROL" works, "CTRL" doesnt.
These names are available for the normal keys
* "mouse-button-2" etc for mouse buttons
<pre class="mw-collapsible-content">
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
1
2
3
4
5
6
7
8
9
0
RETURN
ESCAPE
BACKSPACE
TAB
SPACE
MINUS
EQUALS
LEFTBRACKET
RIGHTBRACKET
BACKSLASH
NONUSHASH
SEMICOLON
APOSTROPHE
GRAVE
COMMA
PERIOD
SLASH
CAPSLOCK
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
PRINTSCREEN
SCROLLLOCK
PAUSE
INSERT
HOME
PAGEUP
DELETE
END
PAGEDOWN
RIGHT
LEFT
DOWN
UP
NUMLOCKCLEAR
KP_DIVIDE
KP_MULTIPLY
KP_MINUS
KP_PLUS
KP_ENTER
KP_1
KP_2
KP_3
KP_4
KP_5
KP_6
KP_7
KP_8
KP_9
KP_0
KP_PERIOD
NONUSBACKSLASH
APPLICATION
POWER
KP_EQUALS
F13
F14
F15
F16
F17
F18
F19
F20
F21
F22
F23
F24
EXECUTE
HELP
MENU
SELECT
STOP
AGAIN
UNDO
CUT
COPY
PASTE
FIND
MUTE
VOLUMEUP
VOLUMEDOWN
KP_COMMA
KP_EQUALSAS400
INTERNATIONAL1
INTERNATIONAL2
INTERNATIONAL3
INTERNATIONAL4
INTERNATIONAL5
INTERNATIONAL6
INTERNATIONAL7
INTERNATIONAL8
INTERNATIONAL9
LANG1
LANG2
LANG3
LANG4
LANG5
LANG6
LANG7
LANG8
LANG9
ALTERASE
SYSREQ
CANCEL
CLEAR
PRIOR
RETURN2
SEPARATOR
OUT
OPER
CLEARAGAIN
CRSEL
EXSEL
KP_00
KP_000
THOUSANDSSEPARATOR
DECIMALSEPARATOR
CURRENCYUNIT
CURRENCYSUBUNIT
KP_LEFTPAREN
KP_RIGHTPAREN
KP_LEFTBRACE
KP_RIGHTBRACE
KP_TAB
KP_BACKSPACE
KP_A
KP_B
KP_C
KP_D
KP_E
KP_F
KP_XOR
KP_POWER
KP_PERCENT
KP_LESS
KP_GREATER
KP_AMPERSAND
KP_DBLAMPERSAND
KP_VERTICALBAR
KP_DBLVERTICALBAR
KP_COLON
KP_HASH
KP_SPACE
KP_AT
KP_EXCLAM
KP_MEMSTORE
KP_MEMRECALL
KP_MEMCLEAR
KP_MEMADD
KP_MEMSUBTRACT
KP_MEMMULTIPLY
KP_MEMDIVIDE
KP_PLUSMINUS
KP_CLEAR
KP_CLEARENTRY
KP_BINARY
KP_OCTAL
KP_DECIMAL
KP_HEXADECIMAL
LCTRL
LSHIFT
LALT
LGUI
RCTRL
RSHIFT
RALT
RGUI
MODE
AUDIONEXT
AUDIOPREV
AUDIOSTOP
AUDIOPLAY
AUDIOMUTE
MEDIASELECT
WWW
MAIL
CALCULATOR
COMPUTER
AC_SEARCH
AC_HOME
AC_BACK
AC_FORWARD
AC_STOP
AC_REFRESH
AC_BOOKMARKS
BRIGHTNESSDOWN
BRIGHTNESSUP
DISPLAYSWITCH
KBDILLUMTOGGLE
KBDILLUMDOWN
KBDILLUMUP
EJECT
SLEEP
APP1
APP2
AUDIOREWIND
AUDIOFASTFORWARD
</pre>
</div>


=== linked_game_control ===
== Optional properties ==
'''Type''': [[Types/string]]


'''Default''': ""
{{Prototype property|alternative_key_sequence|[[Types/string|string]]|optional=true}}
The alternative keybinding for this control. See [[#key_sequence]].


{{Prototype property|linked_game_control|[[Types/string|string]]|""|optional=true}}
When a custom-input is linked to a game control it won't show up in the control-settings GUI and will fire when the linked control is pressed. [https://forums.factorio.com/53591]
When a custom-input is linked to a game control it won't show up in the control-settings GUI and will fire when the linked control is pressed. [https://forums.factorio.com/53591]


<div class="toccolours mw-collapsible mw-collapsed">
<div class="toccolours mw-collapsible mw-collapsed" style="width: 40em;">
List of internal names of game controls
List of internal names of game controls
<pre class="mw-collapsible-content">
<pre class="mw-collapsible-content">
action-bar-select-page-1
action-bar-select-page-10
action-bar-select-page-2
action-bar-select-page-3
action-bar-select-page-4
action-bar-select-page-5
action-bar-select-page-6
action-bar-select-page-7
action-bar-select-page-8
action-bar-select-page-9
activate-tooltip
add-station
add-temporary-station
alt-zoom-in
alt-zoom-in
alt-zoom-out
alt-zoom-out
build
build
build-ghost
build-ghost
build-with-obstacle-avoidance
cancel-craft
cancel-craft
cancel-craft-5
cancel-craft-5
cancel-craft-all
cancel-craft-all
change-active-quickbar
clear-cursor
clean-cursor
confirm-gui
close-gui
confirm-message
confirm-message
connect-train
connect-train
controller-gui-crafting-tab
controller-gui-logistics-tab
copy
copy-entity-settings
copy-entity-settings
craft
craft
Line 45: Line 314:
craft-all
craft-all
cursor-split
cursor-split
cut
cycle-blueprint-backwards
cycle-blueprint-backwards
cycle-blueprint-forwards
cycle-blueprint-forwards
cycle-clipboard-backwards
cycle-clipboard-forwards
debug-reset-zoom
debug-reset-zoom
debug-reset-zoom-2x
debug-toggle-atlas-gui
debug-toggle-atlas-gui
debug-toggle-autoplace-gui
debug-toggle-basic
debug-toggle-basic
debug-toggle-debug-settings
debug-toggle-debug-settings
debug-toggle-detailed
decrease-ui-scale
debug-toggle-full
disconnect-train
disconnect-train
drag-map
drag-map
drop-cursor
drop-cursor
editor-edit-entity-details
editor-clone-item
editor-remove-entity
editor-delete-item
editor-show-all-difficulties
editor-next-variation
editor-show-easy-difficulty
editor-previous-variation
editor-show-hard-difficulty
editor-remove-scripting-object
editor-show-normal-difficulty
editor-reset-speed
editor-tool-primary-action
editor-set-clone-brush-destination
editor-tool-secondary-action
editor-set-clone-brush-source
editor-speed-down
editor-speed-up
editor-switch-to-surface
editor-tick-once
editor-toggle-pause
fast-entity-split
fast-entity-split
fast-entity-transfer
fast-entity-transfer
flip-blueprint-horizontal
flip-blueprint-vertical
focus-search
focus-search
increase-ui-scale
inventory-split
inventory-split
inventory-transfer
inventory-transfer
kill-statistics
larger-terrain-building-area
larger-terrain-building-area
logistic-networks
logistic-networks
mine
mine
mouse-button-1
mouse-button-2
mouse-button-3
mouse-button-n
mouse-wheel-down
mouse-wheel-left
mouse-wheel-right
mouse-wheel-up
move-down
move-down
move-left
move-left
move-right
move-right
move-up
move-up
next-active-quick-bar
next-player-in-replay
next-weapon
next-weapon
open-character-gui
open-character-gui
open-gui
open-gui
open-item
open-item
open-prototype-explorer-gui
open-prototypes-gui
open-technology-gui
open-technology-gui
open-trains-gui
order-to-follow
paste
paste-entity-settings
paste-entity-settings
pause-game
pause-game
pick-item
pick-item
pick-items
pick-items
place-tag
place-in-chat
place-ping
previous-active-quick-bar
previous-mod
previous-technology
previous-technology
production-statistics
production-statistics
quickbar-1
quick-bar-button-1
quickbar-10
quick-bar-button-1-secondary
quickbar-2
quick-bar-button-10
quickbar-3
quick-bar-button-10-secondary
quickbar-4
quick-bar-button-2
quickbar-5
quick-bar-button-2-secondary
quickbar-6
quick-bar-button-3
quickbar-7
quick-bar-button-3-secondary
quickbar-8
quick-bar-button-4
quickbar-9
quick-bar-button-4-secondary
quick-bar-button-5
quick-bar-button-5-secondary
quick-bar-button-6
quick-bar-button-6-secondary
quick-bar-button-7
quick-bar-button-7-secondary
quick-bar-button-8
quick-bar-button-8-secondary
quick-bar-button-9
quick-bar-button-9-secondary
remove-pole-cables
remove-pole-cables
reset-ui-scale
reverse-rotate
reverse-rotate
reverse-select
rotate
rotate
rotate-active-quick-bars
select-for-blueprint
select-for-blueprint
select-for-cancel-deconstruct
select-for-cancel-deconstruct
Line 125: Line 418:
toggle-filter
toggle-filter
toggle-gui-debug
toggle-gui-debug
toggle-gui-glows
toggle-gui-shadows
toggle-gui-style-view
toggle-map
toggle-map
toggle-menu
toggle-menu
toggle-tips-and-tricks
undo
zoom-in
zoom-in
zoom-out
zoom-out
</pre></div>
</pre></div>


Example to use the same key sequence as the clean-cursor hotkey:
Example to use the same key sequence as the clear-cursor hotkey:
<syntaxhighlight lang="lua">key_sequence = ""
<syntaxhighlight lang="lua">key_sequence = ""
linked_game_control = "clean-cursor"</syntaxhighlight>
linked_game_control = "clear-cursor"</syntaxhighlight>
 
{{Prototype property|consuming|[[Types/ConsumingType|ConsumingType]]|"none"|optional=true}}
Sets whether internal game events associated with the same key sequence should be fired or blocked. If they are fired ("none"), then the custom input event will happen before the internal game event.
 
{{Prototype property|enabled|[[Types/bool|bool]]|true|optional=true}}
If this custom input is enabled. Disabled custom inputs exist but are not used by the game. If disabled, no event is raised when the input is used.
 
{{Prototype property|enabled_while_spectating|[[Types/bool|bool]]|false|optional=true}}
 
{{Prototype property|enabled_while_in_cutscene|[[Types/bool|bool]]|false|optional=true}}


=== consuming ===
{{Prototype property|include_selected_prototype|[[Types/bool|bool]]|false|optional=true}}
'''Type''': [[Types/ConsumingType]]
If true, the type and name of the currently selected prototype will be provided as "selected_prototype" in the raised [https://lua-api.factorio.com/latest/events.html#Custom%20Input%20Events lua event]. This also works in GUI's, not just the game world.[https://forums.factorio.com/96125]


'''Default''': "none"
This will also return an item in the cursor such as copper-wire or rail-planner, if nothing is beneath the cursor.


=== enabled ===
{{Prototype property|item_to_spawn|[[Types/string|string]]|optional=true}}
'''Type''': [[Types/bool]]
Name of a [[Prototype/Item]]. It will be created when this input is pressed and action is set to "spawn-item". The item must have the [[Types/ItemPrototypeFlags#.22spawnable.22|"spawnable"]] flag set.


'''Default''': true
{{Prototype property|action|[[Types/string|string]]|"lua"|optional=true}}
One of "lua", "spawn-item", "toggle-personal-roboport", "toggle-personal-logistic-requests" and "toggle-equipment-movement-bonus".


If this custom input is enabled. Disabled custom inputs exist but are not used by the game.
A [https://lua-api.factorio.com/latest/events.html#Custom%20Input%20Events lua event] is only raised if the action is "lua".

Latest revision as of 15:28, 9 June 2022

Prototype definitions » PrototypeBase » Prototype/CustomInput


Used for custom keyboard shortcuts/keybindings in mods. The key associated with the custom input can be changed in the options. This means that key_sequence is simply the default keybinding.


Prototype/CustomInput — custom-input
key_sequence::string
action::string (optional)
alternative_key_sequence::string (optional)
consuming::ConsumingType (optional)
enabled::bool (optional)
enabled_while_in_cutscene::bool (optional)
enabled_while_spectating::bool (optional)
include_selected_prototype::bool (optional)
item_to_spawn::string (optional)
linked_game_control::string (optional)
Inherited from PrototypeBase
name::string
type::string
localised_description::LocalisedString (optional)
localised_name::LocalisedString (optional)
order::Order (optional)

Mandatory properties

Inherits all properties from PrototypeBase.

name

See PrototypeBase#name

Inherited from PrototypeBase. It is also the name for the event that is raised when they key (combination) is pressed and action is "lua", see Tutorial:Script interfaces.

key_sequence

Type: string
The default key sequence for this custom input.

  • "" (empty string) for unassigned
  • "mouse-button-2" etc for mouse buttons, mouse-button-3 for middle mouse button
  • "mouse-wheel-up", "mouse-wheel-down", "mouse-wheel-left", "mouse-wheel-right" for mouse wheel
  • " + " is used to separate modifier keys from normal keys: "ALT + G"
  • For modifier keys, the following names are used: "CONTROL", "SHIFT", "ALT", "COMMAND"
  • A keybinding can contain an unlimited amount of modifier keys (listed above) but only one normal key (listed below).

These names are available for the normal keys

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
1
2
3
4
5
6
7
8
9
0
RETURN
ESCAPE
BACKSPACE
TAB
SPACE
MINUS
EQUALS
LEFTBRACKET
RIGHTBRACKET
BACKSLASH
NONUSHASH
SEMICOLON
APOSTROPHE
GRAVE
COMMA
PERIOD
SLASH
CAPSLOCK
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
PRINTSCREEN
SCROLLLOCK
PAUSE
INSERT
HOME
PAGEUP
DELETE
END
PAGEDOWN
RIGHT
LEFT
DOWN
UP
NUMLOCKCLEAR
KP_DIVIDE
KP_MULTIPLY
KP_MINUS
KP_PLUS
KP_ENTER
KP_1
KP_2
KP_3
KP_4
KP_5
KP_6
KP_7
KP_8
KP_9
KP_0
KP_PERIOD
NONUSBACKSLASH
APPLICATION
POWER
KP_EQUALS
F13
F14
F15
F16
F17
F18
F19
F20
F21
F22
F23
F24
EXECUTE
HELP
MENU
SELECT
STOP
AGAIN
UNDO
CUT
COPY
PASTE
FIND
MUTE
VOLUMEUP
VOLUMEDOWN
KP_COMMA
KP_EQUALSAS400
INTERNATIONAL1
INTERNATIONAL2
INTERNATIONAL3
INTERNATIONAL4
INTERNATIONAL5
INTERNATIONAL6
INTERNATIONAL7
INTERNATIONAL8
INTERNATIONAL9
LANG1
LANG2
LANG3
LANG4
LANG5
LANG6
LANG7
LANG8
LANG9
ALTERASE
SYSREQ
CANCEL
CLEAR
PRIOR
RETURN2
SEPARATOR
OUT
OPER
CLEARAGAIN
CRSEL
EXSEL
KP_00
KP_000
THOUSANDSSEPARATOR
DECIMALSEPARATOR
CURRENCYUNIT
CURRENCYSUBUNIT
KP_LEFTPAREN
KP_RIGHTPAREN
KP_LEFTBRACE
KP_RIGHTBRACE
KP_TAB
KP_BACKSPACE
KP_A
KP_B
KP_C
KP_D
KP_E
KP_F
KP_XOR
KP_POWER
KP_PERCENT
KP_LESS
KP_GREATER
KP_AMPERSAND
KP_DBLAMPERSAND
KP_VERTICALBAR
KP_DBLVERTICALBAR
KP_COLON
KP_HASH
KP_SPACE
KP_AT
KP_EXCLAM
KP_MEMSTORE
KP_MEMRECALL
KP_MEMCLEAR
KP_MEMADD
KP_MEMSUBTRACT
KP_MEMMULTIPLY
KP_MEMDIVIDE
KP_PLUSMINUS
KP_CLEAR
KP_CLEARENTRY
KP_BINARY
KP_OCTAL
KP_DECIMAL
KP_HEXADECIMAL
LCTRL
LSHIFT
LALT
LGUI
RCTRL
RSHIFT
RALT
RGUI
MODE
AUDIONEXT
AUDIOPREV
AUDIOSTOP
AUDIOPLAY
AUDIOMUTE
MEDIASELECT
WWW
MAIL
CALCULATOR
COMPUTER
AC_SEARCH
AC_HOME
AC_BACK
AC_FORWARD
AC_STOP
AC_REFRESH
AC_BOOKMARKS
BRIGHTNESSDOWN
BRIGHTNESSUP
DISPLAYSWITCH
KBDILLUMTOGGLE
KBDILLUMDOWN
KBDILLUMUP
EJECT
SLEEP
APP1
APP2
AUDIOREWIND
AUDIOFASTFORWARD

Optional properties

alternative_key_sequence

Type: string
The alternative keybinding for this control. See #key_sequence.

linked_game_control

Type: string
Default: ""
When a custom-input is linked to a game control it won't show up in the control-settings GUI and will fire when the linked control is pressed. [1]

List of internal names of game controls

action-bar-select-page-1
action-bar-select-page-10
action-bar-select-page-2
action-bar-select-page-3
action-bar-select-page-4
action-bar-select-page-5
action-bar-select-page-6
action-bar-select-page-7
action-bar-select-page-8
action-bar-select-page-9
activate-tooltip
add-station
add-temporary-station
alt-zoom-in
alt-zoom-out
build
build-ghost
build-with-obstacle-avoidance
cancel-craft
cancel-craft-5
cancel-craft-all
clear-cursor
confirm-gui
confirm-message
connect-train
controller-gui-crafting-tab
controller-gui-logistics-tab
copy
copy-entity-settings
craft
craft-5
craft-all
cursor-split
cut
cycle-blueprint-backwards
cycle-blueprint-forwards
cycle-clipboard-backwards
cycle-clipboard-forwards
debug-reset-zoom
debug-reset-zoom-2x
debug-toggle-atlas-gui
debug-toggle-basic
debug-toggle-debug-settings
decrease-ui-scale
disconnect-train
drag-map
drop-cursor
editor-clone-item
editor-delete-item
editor-next-variation
editor-previous-variation
editor-remove-scripting-object
editor-reset-speed
editor-set-clone-brush-destination
editor-set-clone-brush-source
editor-speed-down
editor-speed-up
editor-switch-to-surface
editor-tick-once
editor-toggle-pause
fast-entity-split
fast-entity-transfer
flip-blueprint-horizontal
flip-blueprint-vertical
focus-search
increase-ui-scale
inventory-split
inventory-transfer
larger-terrain-building-area
logistic-networks
mine
move-down
move-left
move-right
move-up
next-active-quick-bar
next-player-in-replay
next-weapon
open-character-gui
open-gui
open-item
open-prototype-explorer-gui
open-prototypes-gui
open-technology-gui
open-trains-gui
order-to-follow
paste
paste-entity-settings
pause-game
pick-item
pick-items
place-in-chat
place-ping
previous-active-quick-bar
previous-mod
previous-technology
production-statistics
quick-bar-button-1
quick-bar-button-1-secondary
quick-bar-button-10
quick-bar-button-10-secondary
quick-bar-button-2
quick-bar-button-2-secondary
quick-bar-button-3
quick-bar-button-3-secondary
quick-bar-button-4
quick-bar-button-4-secondary
quick-bar-button-5
quick-bar-button-5-secondary
quick-bar-button-6
quick-bar-button-6-secondary
quick-bar-button-7
quick-bar-button-7-secondary
quick-bar-button-8
quick-bar-button-8-secondary
quick-bar-button-9
quick-bar-button-9-secondary
remove-pole-cables
reset-ui-scale
reverse-rotate
reverse-select
rotate
rotate-active-quick-bars
select-for-blueprint
select-for-cancel-deconstruct
shoot-enemy
shoot-selected
show-info
smaller-terrain-building-area
smart-pipette
stack-split
stack-transfer
toggle-blueprint-library
toggle-console
toggle-driving
toggle-filter
toggle-gui-debug
toggle-gui-glows
toggle-gui-shadows
toggle-gui-style-view
toggle-map
toggle-menu
undo
zoom-in
zoom-out

Example to use the same key sequence as the clear-cursor hotkey:

key_sequence = ""
linked_game_control = "clear-cursor"

consuming

Type: ConsumingType
Default: "none"
Sets whether internal game events associated with the same key sequence should be fired or blocked. If they are fired ("none"), then the custom input event will happen before the internal game event.

enabled

Type: bool
Default: true
If this custom input is enabled. Disabled custom inputs exist but are not used by the game. If disabled, no event is raised when the input is used.

enabled_while_spectating

Type: bool
Default: false

enabled_while_in_cutscene

Type: bool
Default: false

include_selected_prototype

Type: bool
Default: false
If true, the type and name of the currently selected prototype will be provided as "selected_prototype" in the raised lua event. This also works in GUI's, not just the game world.[2]

This will also return an item in the cursor such as copper-wire or rail-planner, if nothing is beneath the cursor.

item_to_spawn

Type: string
Name of a Prototype/Item. It will be created when this input is pressed and action is set to "spawn-item". The item must have the "spawnable" flag set.

action

Type: string
Default: "lua"
One of "lua", "spawn-item", "toggle-personal-roboport", "toggle-personal-logistic-requests" and "toggle-equipment-movement-bonus".

A lua event is only raised if the action is "lua".