Page 1 of 1

set_shortcut_available for all shortcuts

Posted: Fri Aug 21, 2020 2:27 pm
by ickputzdirwech
Right now you can use set_shortcut_available(prototype_name, available) only for shortcuts with action = "lua". It would be nice if you could use it for all shortcuts.

Re: set_shortcut_available for all shortcuts

Posted: Tue Sep 01, 2020 8:59 am
by ickputzdirwech
Maybe a bit of context why this would be useful helps ;)

Modded shortcuts often only make sense if you have researched a specific technology. For example a shortcut for the Module Inserter mod in my eyes only makes sense if you have modules researched. But you can't use the following script since the shortcut "module-inserter" uses the action = "create-blueprint-item". In order to use set_shortcut_available you have to change the action to "lua" and give the item to the player via a custom script (as implemented by Shortcuts for 1.0). It would be way simpler if you could just use set_shortcut_available for all actions. Especially since in 1.1.0 it will be possible again to give the player other items than selection-tools via action = "create-blueprint-item" again like a artillery-targeting-remote. (if I understand this topic 87777 correctly.

Code: Select all

script.on_event(defines.events.on_player_created, function(event)
	if player.force.technologies["modules"].researched == false then
		player.set_shortcut_available("module-inserter", false)
	end
end)

script.on_event(defines.events.on_research_finished, function(event)
	for _,player in pairs(event.research.force.players) do
		if event.research and event.research.name == "modules" then
			player.set_shortcut_available("module-inserter", true)
		end
	end
end)