How does technology_to_unlock work for Prototype/Shortcut?

Place to get help with not working mods / modding interface.
Post Reply
Pi-C
Smart Inserter
Smart Inserter
Posts: 1274
Joined: Sun Oct 14, 2018 8:13 am
Contact:

How does technology_to_unlock work for Prototype/Shortcut?

Post by Pi-C »

I've defined this prototype:

Code: Select all

  {
    type = "shortcut",
    name = "GCKI_car-key",
    action = "lua",
    icon = {
      filename = GCKI.modRoot.."/graphics/"..icon,
      size = 64,
      mipmap_count = 1,
    },
    technology_to_unlock = "automobilism",
  },
I expected that the shortcut would not be visible until "automobilism" was researched. But when I started a new game without cheats, the shortcut was visible right from the beginning.

In control.lua, there is this:

Code: Select all

script.on_event(defines.events.on_lua_shortcut, function(event)
 log("on_lua_shortcut("..serpent.line(event)..")")
end)
The log file shows that the shortcut is not only visible, but also active. So, where is my mistake?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
ickputzdirwech
Filter Inserter
Filter Inserter
Posts: 704
Joined: Sun May 07, 2017 10:16 am
Contact:

Re: How does technology_to_unlock work for Prototype/Shortcut?

Post by ickputzdirwech »

Rather unexpectedly technology_to_unlock means the shortcut will be available if you researched that technology already in any game. It is used by the base game for the blueprint shortcuts that are supposed to be only available later in the game for new players, but right from the start for experienced players.

To achieve your goal you need enable the shortcut in control.lua on_research_finished with set_shortcut_available
Mods: Shortcuts for 1.1, ick's Sea Block, ick's vanilla tweaks
Tools: Atom language pack
Text quickly seems cold and unfriendly. Be careful how you write and interpret what others have written.
- A reminder for me and all who read what I write

Pi-C
Smart Inserter
Smart Inserter
Posts: 1274
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: How does technology_to_unlock work for Prototype/Shortcut?

Post by Pi-C »

ickputzdirwech wrote:
Mon May 02, 2022 6:26 am
Rather unexpectedly technology_to_unlock means the shortcut will be available if you researched that technology already in any game.
Oh, I see! That's really unexpected, it definitely should be documented.
To achieve your goal you need enable the shortcut in control.lua on_research_finished with set_shortcut_available
Thanks, I've added this (as well as disabling the shortcut in response to on_research_reversed). It seems to work now. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Post Reply

Return to “Modding help”