From f0f90c2b591ce9b917e4f24bbd73e00293d742e9 Mon Sep 17 00:00:00 2001 From: bgkillas Date: Mon, 18 Nov 2024 08:26:26 -0500 Subject: [PATCH] make chest logic a bit more general --- quant.ew/files/system/item_sync.lua | 38 ++++++++++------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/quant.ew/files/system/item_sync.lua b/quant.ew/files/system/item_sync.lua index 112d1b0b..db5492b1 100644 --- a/quant.ew/files/system/item_sync.lua +++ b/quant.ew/files/system/item_sync.lua @@ -20,26 +20,21 @@ local dead_entities = {} function rpc.open_chest(gid) local ent = item_sync.find_by_gid(gid) - if ent ~= nil then - local name = EntityGetFilename(ent) - local file - if name == "data/entities/items/pickup/utility_box.xml" then - file = "data/scripts/items/utility_box.lua" - end - if name == "data/entities/items/pickup/chest_random_super.xml" then - file = "data/scripts/items/chest_random_super.lua" - end - if name == "data/entities/items/pickup/chest_random.xml" then - file = "data/scripts/items/chest_random.lua" - end - if file ~= nil then - EntityAddComponent2(ent, "LuaComponent", { - script_source_file = file, - execute_on_added = true, - call_init_function = true, - }) + local file + for _, com in ipairs(EntityGetComponent(ent, "LuaComponent")) do + local f = ComponentGetValue2(com, "script_item_picked_up") + if f ~= nil then + file = f + break end end + if file ~= nil then + EntityAddComponent2(ent, "LuaComponent", { + script_source_file = file, + execute_on_added = true, + call_init_function = true, + }) + end end util.add_cross_call("ew_chest_opened", function(chest_id) @@ -223,13 +218,6 @@ function item_sync.make_item_global(item, instant, give_authority_to) }) end - local name = EntityGetName(item) - if name == "$item_utility_box" - or name == "$item_chest_treasure" - or name == "$item_chest_treasure_super" then - - end - ctx.item_prevent_localize[gid] = false rpc.item_globalize(item_data) end)