Prototype/Shortcut: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(disabled_small_icon's default behaviour changed in 1.1.37 to inherit from disabled_icon instead of icon. Added internal links (`icon` -> `#icon`))
(Removed old prototype docs)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Prototype parent|PrototypeBase}}
<div class="stub"><p>'''The prototype docs have moved to a new website with an improved format.''' This documentation page can now be found here: [https://lua-api.factorio.com/latest/prototypes/ShortcutPrototype.html https://lua-api.factorio.com/latest/prototypes/ShortcutPrototype.html]
Definition for a shortcut button in the [[shortcut bar]].<br>
This is ''not'' a custom keybinding (keyboard shortcut), for that see [[Prototype/CustomInput]]


{{Prototype TOC|shortcut}}
</p><p>This wiki page is no longer updated and '''will be removed at some point in the future''', so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback [https://forums.factorio.com/viewforum.php?f=233 on the forums].</p></div>
 
== Mandatory properties ==
Inherits all properties from [[PrototypeBase]].
 
{{Prototype property|action|[[Types/string|string]]}}
One of "toggle-alt-mode", "undo", "copy", "cut", "paste", "import-string", "toggle-personal-roboport", "toggle-equipment-movement-bonus", "spawn-item" and "lua".
 
{{Prototype property|icon|[[Types/Sprite|Sprite]]}}
Scales to fit a 16x16-pixel square.<br />
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.
 
== Optional properties ==
 
{{Prototype property|item_to_spawn|[[Types/string|string]]|optional=true}}
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 [[Types/ItemPrototypeFlags#.22spawnable.22|"spawnable"]] flag set.
 
{{Prototype property|technology_to_unlock|[[Types/string|string]]|optional=true}}
Name of a [[Prototype/Technology]]. The technology that must be researched before this shortcut can be used.
 
{{Prototype property|toggleable|[[Types/bool|bool]]|false|optional=true}}
Must be enabled for the Factorio API to be able to set the toggled state on the shortcut button, see [https://lua-api.factorio.com/latest/LuaPlayer.html#LuaPlayer.set_shortcut_toggled LuaPlayer.set_shortcut_toggled].
 
{{Prototype property|associated_control_input|[[Types/string|string]]|""|optional=true}}
Name of a custom input or vanilla control. Used to show the keybind in the tooltip of the shortcut.
 
{{Prototype property|small_icon|[[Types/Sprite|Sprite]]|Uses [[#icon]] definition|optional=true}}
The icon used in the panel for visible shortcuts, when the shortcut is usable.<br />
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.
 
{{Prototype property|disabled_icon|[[Types/Sprite|Sprite]]|Uses [[#icon]] definition|optional=true}}
The icon used when the shortcut is shown in the quickbar, and is not usable.<br />
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.
 
{{Prototype property|disabled_small_icon|[[Types/Sprite|Sprite]]| Uses [[#disabled_icon]] definition|optional=true}}
The icon used in the panel for visible shortcuts, when the shortcut is not usable.<br />
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.
 
{{Prototype property|style|[[Types/string|string]]|"default"|optional=true}}
One of "default", "blue", "red" and "green".
 
== Example ==
 
<syntaxhighlight lang="lua">  {
    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"}
    }
  }</syntaxhighlight>

Latest revision as of 14:33, 25 October 2024

The prototype docs have moved to a new website with an improved format. This documentation page can now be found here: https://lua-api.factorio.com/latest/prototypes/ShortcutPrototype.html

This wiki page is no longer updated and will be removed at some point in the future, so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback on the forums.