mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
make chest logic a bit more general
This commit is contained in:
parent
edb4a4ccde
commit
f0f90c2b59
1 changed files with 13 additions and 25 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue