Prototype/Shortcut: Difference between revisions
(1.1) |
(→Example: Updated to 1.1.34) |
||
Line 38: | Line 38: | ||
== Example == | == Example == | ||
<syntaxhighlight lang="lua">{ | <syntaxhighlight lang="lua"> { | ||
type = "shortcut", | type = "shortcut", | ||
name = "give-deconstruction-planner", | name = "give-deconstruction-planner", | ||
order = "b[blueprints]-g[deconstruction-planner]", | order = "b[blueprints]-g[deconstruction-planner]", | ||
action = " | action = "spawn-item", | ||
localised_name = {"shortcut.make-deconstruction-planner"}, | localised_name = {"shortcut.make-deconstruction-planner"}, | ||
associated_control_input = "give-deconstruction-planner", | |||
technology_to_unlock = "construction-robotics", | technology_to_unlock = "construction-robotics", | ||
item_to_spawn = "deconstruction-planner", | |||
style = "red", | style = "red", | ||
icon = | icon = | ||
{ | { | ||
filename = "__base__/graphics/icons/shortcut-toolbar/new-deconstruction-planner-x32-white.png", | filename = "__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x32-white.png", | ||
priority = "extra-high-no-scale", | priority = "extra-high-no-scale", | ||
size = 32, | size = 32, | ||
scale = | scale = 0.5, | ||
flags = {"icon"} | mipmap_count = 2, | ||
flags = {"gui-icon"} | |||
}, | }, | ||
small_icon = | small_icon = | ||
{ | { | ||
filename = "__base__/graphics/icons/shortcut-toolbar/new-deconstruction-planner-x24.png", | filename = "__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x24-white.png", | ||
priority = "extra-high-no-scale", | priority = "extra-high-no-scale", | ||
size = 24, | size = 24, | ||
scale = | scale = 0.5, | ||
flags = {"icon"} | mipmap_count = 2, | ||
flags = {"gui-icon"} | |||
}, | }, | ||
disabled_small_icon = | disabled_small_icon = | ||
{ | { | ||
filename = "__base__/graphics/icons/shortcut-toolbar/new-deconstruction-planner-x24-white.png", | filename = "__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x24-white.png", | ||
priority = "extra-high-no-scale", | priority = "extra-high-no-scale", | ||
size = 24, | size = 24, | ||
scale = | scale = 0.5, | ||
flags = {"icon"} | mipmap_count = 2, | ||
} | flags = {"gui-icon"} | ||
} | |||
}</syntaxhighlight> | }</syntaxhighlight> |
Revision as of 18:57, 9 June 2021
Prototype definitions » PrototypeBase » Prototype/Shortcut
Definition for a shortcut button in the shortcut bar.
This is not a custom keybinding (keyboard shortcut), for that see Prototype/CustomInput
Prototype/Shortcut — shortcut | ||
action | :: | string |
icon | :: | Sprite |
associated_control_input | :: | string (optional) |
disabled_icon | :: | Sprite (optional) |
disabled_small_icon | :: | Sprite (optional) |
item_to_spawn | :: | string (optional) |
small_icon | :: | Sprite (optional) |
style | :: | string (optional) |
technology_to_unlock | :: | string (optional) |
toggleable | :: | bool (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.
action
Type: string
One of "toggle-alt-mode", "undo", "copy", "cut", "paste", "import-string", "toggle-personal-roboport", "toggle-equipment-movement-bonus", "spawn-item" and "lua".
icon
Type: Sprite
Optional properties
item_to_spawn
Type: string
Name of a Prototype/Item. The item to create when clicking on a shortcut with the action set to "spawn-item". The item must have the "spawnable" flag set.
technology_to_unlock
Type: string
Name of a Prototype/Technology. The technology that must be researched before this shortcut can be used.
toggleable
Type: bool
Default: false
Must be enabled for the Factorio API to be able to set the toggled state on the shortcut button, see LuaPlayer.set_shortcut_toggled.
associated_control_input
Type: string
Default: ""
Name of a custom input or vanilla control. Used to show the keybind in the tooltip of the shortcut.
small_icon
Type: Sprite
disabled_icon
Type: Sprite
disabled_small_icon
Type: Sprite
style
Type: string
Default: "default"
One of "default", "blue", "red" and "green".
Example
{
type = "shortcut",
name = "give-deconstruction-planner",
order = "b[blueprints]-g[deconstruction-planner]",
action = "spawn-item",
localised_name = {"shortcut.make-deconstruction-planner"},
associated_control_input = "give-deconstruction-planner",
technology_to_unlock = "construction-robotics",
item_to_spawn = "deconstruction-planner",
style = "red",
icon =
{
filename = "__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x32-white.png",
priority = "extra-high-no-scale",
size = 32,
scale = 0.5,
mipmap_count = 2,
flags = {"gui-icon"}
},
small_icon =
{
filename = "__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x24-white.png",
priority = "extra-high-no-scale",
size = 24,
scale = 0.5,
mipmap_count = 2,
flags = {"gui-icon"}
},
disabled_small_icon =
{
filename = "__base__/graphics/icons/shortcut-toolbar/mip/new-deconstruction-planner-x24-white.png",
priority = "extra-high-no-scale",
size = 24,
scale = 0.5,
mipmap_count = 2,
flags = {"gui-icon"}
}
}