mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 08:23:12 +09:00
Sync every toggleable shortcut instead of a fixed list
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
75ac8bb491
commit
d9bce1e39e
1 file changed
+4
-10
@@ -602,19 +602,12 @@ end
|
|||||||
--- @field crafting_queue table?
|
--- @field crafting_queue table?
|
||||||
--- @field recipe_notifications string?
|
--- @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
|
--- @param player LuaPlayer
|
||||||
--- @return table<string, boolean>
|
--- @return table<string, boolean>
|
||||||
function serialize.serialize_shortcuts(player)
|
function serialize.serialize_shortcuts(player)
|
||||||
local shortcut_prototypes = compat.prototypes.shortcut
|
|
||||||
local shortcuts = {}
|
local shortcuts = {}
|
||||||
for _, name in ipairs(synced_shortcuts) do
|
for name, prototype in pairs(compat.prototypes.shortcut) do
|
||||||
if shortcut_prototypes[name] then
|
if prototype.toggleable then
|
||||||
shortcuts[name] = player.is_shortcut_toggled(name)
|
shortcuts[name] = player.is_shortcut_toggled(name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -626,7 +619,8 @@ end
|
|||||||
function serialize.deserialize_shortcuts(player, serialized)
|
function serialize.deserialize_shortcuts(player, serialized)
|
||||||
local shortcut_prototypes = compat.prototypes.shortcut
|
local shortcut_prototypes = compat.prototypes.shortcut
|
||||||
for name, toggled in pairs(serialized) do
|
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)
|
player.set_shortcut_toggled(name, toggled)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user