This commit is contained in:
2025-01-14 13:26:49 +09:00
parent c10de39a89
commit 843de85206
4 changed files with 19 additions and 21 deletions

View File

@@ -82,7 +82,7 @@ authorities.character_only =
--- If a command has the flag "remote_only" then the command can only be used inside of remote view --- If a command has the flag "remote_only" then the command can only be used inside of remote view
authorities.remote_only = authorities.remote_only =
add(function(player, command) add(function(player, command)
if command.flags.character_only and player.controller_type ~= defines.controllers.remote then if command.flags.remote_only and player.controller_type ~= defines.controllers.remote then
return deny{ "exp-commands-authorities.remote-only" } return deny{ "exp-commands-authorities.remote-only" }
else else
return allow() return allow()

View File

@@ -152,14 +152,12 @@ if config.auto_collect_bodies then
Event.add(defines.events.on_character_corpse_expired, function(event) Event.add(defines.events.on_character_corpse_expired, function(event)
local corpse = event.corpse local corpse = event.corpse
local inventory = assert(corpse.get_inventory(defines.inventory.character_corpse)) local inventory = assert(corpse.get_inventory(defines.inventory.character_corpse))
--[[
ExpUtil.transfer_inventory_to_surface{ ExpUtil.transfer_inventory_to_surface{
inventory = inventory, inventory = inventory,
surface = corpse.surface, surface = corpse.surface,
name = "steel-chest", name = "steel-chest",
allow_creation = true, allow_creation = true,
} }
]]
end) end)
end end

View File

@@ -403,6 +403,7 @@ end
function ExpUtil.get_storage_for_stack(options) function ExpUtil.get_storage_for_stack(options)
local surface = assert(options.surface, "A surface must be provided") local surface = assert(options.surface, "A surface must be provided")
local item = assert(options.item, "An item stack must be provided") local item = assert(options.item, "An item stack must be provided")
assert(type(item) ~= "userdata" or item.valid_for_read, "Invalid stack provided")
-- Perform a search if on has not been done already -- Perform a search if on has not been done already
local cache = options.cache local cache = options.cache
@@ -420,16 +421,6 @@ function ExpUtil.get_storage_for_stack(options)
local current, count, entities = cache.current, cache.count, cache.entities local current, count, entities = cache.current, cache.count, cache.entities
for i = 1, cache.count do for i = 1, cache.count do
local entity = entities[((current + i - 1) % count) + 1] local entity = entities[((current + i - 1) % count) + 1]
if entity == nil then
-- See Github Issue #352 <https://github.com/explosivegaming/ExpCluster/issues/352>
error("entity was nil, context:\n" .. ExpUtil.format_any({
cache = cache,
i = i,
}, {
max_line_count = 0,
no_locale_strings = true
}))
end
if entity.can_insert(item) then if entity.can_insert(item) then
cache.current = current + 1 cache.current = current + 1
return entity return entity
@@ -454,7 +445,7 @@ function ExpUtil.get_storage_for_stack(options)
assert(entity, "Failed to create a new entity") assert(entity, "Failed to create a new entity")
cache.count = count + 1 cache.count = count + 1
entities[count] = entity entities[count + 1] = entity
return entity return entity
end end
@@ -468,10 +459,13 @@ end
function ExpUtil.copy_items_to_surface(options) function ExpUtil.copy_items_to_surface(options)
local entity local entity
for item_index = 1, #options.items do for item_index = 1, #options.items do
options.item = options.items[item_index] local item = options.items[item_index]
if type(item) ~= "userdata" or item.valid_for_read then
options.item = item
entity = ExpUtil.get_storage_for_stack(options) entity = ExpUtil.get_storage_for_stack(options)
entity.insert(options.item) entity.insert(options.item)
end end
end
return entity return entity
end end
@@ -485,11 +479,14 @@ end
function ExpUtil.move_items_to_surface(options) function ExpUtil.move_items_to_surface(options)
local entity local entity
for item_index = 1, #options.items do for item_index = 1, #options.items do
options.item = options.items[item_index] local item = options.items[item_index]
if type(item) ~= "userdata" or item.valid_for_read then
options.item = item
entity = ExpUtil.get_storage_for_stack(options) entity = ExpUtil.get_storage_for_stack(options)
entity.insert(options.item) entity.insert(options.item)
options.item.clear() options.item.clear()
end end
end
return entity return entity
end end

View File

@@ -29,7 +29,10 @@ script = {
--- ---
--- Type patched in 2.0.28: [Bug Report](https://forums.factorio.com/viewtopic.php?f=233&t=125062) --- Type patched in 2.0.28: [Bug Report](https://forums.factorio.com/viewtopic.php?f=233&t=125062)
--- Changed "event" from "string | integer" to "LuaEventType" --- Changed "event" from "string | integer" to "LuaEventType"
--- Resolved in 2.0.29, this patch will be removed was version is stable
---@param event LuaEventType ID or name of the event to raise. ---@param event LuaEventType ID or name of the event to raise.
---@param data table Table with extra data that will be passed to the event handler. Any invalid LuaObjects will silently stop the event from being raised. ---@param data table Table with extra data that will be passed to the event handler. Any invalid LuaObjects will silently stop the event from being raised.
raise_event = function(event, data) end; raise_event = function(event, data) end;
} }
---@class LuaObject:userdata
--https://github.com/justarandomgeek/vscode-factoriomod-debug/issues/165