Factorio Prototype DocsVersion 1.1.107

ShortcutPrototype - 'shortcut' Example code

Definition for a shortcut button in the shortcut bar.

This is not a custom keybinding (keyboard shortcut), for that see CustomInputPrototype.

Inherits from PrototypeBase

Properties

action :: "toggle-alt-mode" or "undo" or "copy" or "cut" or "paste" or "import-string" or "toggle-personal-roboport" or "toggle-equipment-movement-bonus" or "spawn-item" or "lua"

If this is "lua", on_lua_shortcut is raised when the shortcut is clicked.

If this is "lua", on_lua_shortcut is raised when the shortcut is clicked.

icon :: Sprite

Scales to fit a 16x16-pixel square. [...]

Scales to fit a 16x16-pixel square. [...]

item_to_spawn optional :: ItemID

The item to create when clicking on a shortcut with the action set to "spawn-item". [...]

The item to create when clicking on a shortcut with the action set to "spawn-item". [...]

technology_to_unlock optional :: TechnologyID

The technology that must be researched before this shortcut can be used. [...]

The technology that must be researched before this shortcut can be used. [...]

toggleable optional :: bool

Must be enabled for the Factorio API to be able to set the toggled state on the shortcut button, see LuaPlayer::set_shortcut_toggled.

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 optional :: string

Name of a custom input or vanilla control. [...]

Name of a custom input or vanilla control. [...]

small_icon optional :: Sprite

The icon used in the panel for visible shortcuts, when the shortcut is usable. [...]

The icon used in the panel for visible shortcuts, when the shortcut is usable. [...]

disabled_icon optional :: Sprite

The icon used when the shortcut is shown in the quickbar, and is not usable. [...]

The icon used when the shortcut is shown in the quickbar, and is not usable. [...]

disabled_small_icon optional :: Sprite

The icon used in the panel for visible shortcuts, when the shortcut is not usable. [...]

The icon used in the panel for visible shortcuts, when the shortcut is not usable. [...]

style optional :: "default" or "blue" or "red" or "green"

Inherited from PrototypeBase
type :: string

Specifies the kind of prototype this is. [...]

Specifies the kind of prototype this is. [...]

name :: string

Unique textual identification of the prototype. [...]

Unique textual identification of the prototype. [...]

order[overridden] optional :: Order

Used to order prototypes in inventory, recipes and GUIs. [...]

Used to order prototypes in inventory, recipes and GUIs. [...]

localised_name optional :: LocalisedString

Overwrites the name set in the locale file. [...]

Overwrites the name set in the locale file. [...]

localised_description optional :: LocalisedString

Overwrites the description set in the locale file. [...]

Overwrites the description set in the locale file. [...]

Properties

action :: "toggle-alt-mode" or "undo" or "copy" or "cut" or "paste" or "import-string" or "toggle-personal-roboport" or "toggle-equipment-movement-bonus" or "spawn-item" or "lua"

If this is "lua", on_lua_shortcut is raised when the shortcut is clicked.

icon :: Sprite

Scales to fit a 16x16-pixel square.

Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.

item_to_spawn :: ItemID optional

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 :: TechnologyID optional

The technology that must be researched before this shortcut can be used. Once a shortcut is unlocked in one save file, it is unlocked for all future save files.

toggleable :: bool optional

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 :: string optional

Default: ""

Name of a custom input or vanilla control. This is only used to show the keybind in the tooltip of the shortcut.

small_icon :: Sprite optional

Default: Uses icon definition

The icon used in the panel for visible shortcuts, when the shortcut is usable.

Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.

disabled_icon :: Sprite optional

Default: Uses icon definition

The icon used when the shortcut is shown in the quickbar, and is not usable.

Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.

disabled_small_icon :: Sprite optional

Default: Uses disabled_icon definition

The icon used in the panel for visible shortcuts, when the shortcut is not usable.

Note: The scale that can be defined in the sprite may not behave as expected because the game always scales the sprite to fill the GUI slot.

style :: "default" or "blue" or "red" or "green" optional

Default: "default"

Overridden Properties

order :: Order optional

Default: ""

Used to order the shortcuts in the quick panel, which replaces the shortcut bar when using a controller (game pad). It is recommended to order modded shortcuts after the vanilla shortcuts.

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,
    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,
    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,
    mipmap_count = 2,
    flags = {"gui-icon"}
  }
}

Prototypes

Types