Sync every toggleable shortcut instead of a fixed list

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Fable 5.1 committed 2026-09-06 01:10:43 +00:00
1 parent 75ac8bb491
commit d9bce1e39e
1 file changed
+4 -10
+4 -10
View File
@@ -602,19 +602,12 @@ end
--- @field crafting_queue table?
--- @field recipe_notifications string?
--- Toggle shortcuts whose state is stored on the player and not covered by any other synced data
local synced_shortcuts = {
"toggle-personal-roboport",
"toggle-equipment-movement-bonus",
}
--- @param player LuaPlayer
--- @return table<string, boolean>
function serialize.serialize_shortcuts(player)
local shortcut_prototypes = compat.prototypes.shortcut
local shortcuts = {}
for _, name in ipairs(synced_shortcuts) do
if shortcut_prototypes[name] then
for name, prototype in pairs(compat.prototypes.shortcut) do
if prototype.toggleable then
shortcuts[name] = player.is_shortcut_toggled(name)
end
end
@@ -626,7 +619,8 @@ end
function serialize.deserialize_shortcuts(player, serialized)
local shortcut_prototypes = compat.prototypes.shortcut
for name, toggled in pairs(serialized) do
if shortcut_prototypes[name] then
local prototype = shortcut_prototypes[name]
if prototype and prototype.toggleable then
player.set_shortcut_toggled(name, toggled)
end
end