remove some errors

This commit is contained in:
bgkillas 2024-08-20 09:42:47 -04:00
parent 749025b2ef
commit b35db32101
2 changed files with 8 additions and 6 deletions

View file

@ -120,14 +120,16 @@ function item_sync.make_item_global(item, instant)
return
end
item_sync.ensure_notify_component(item)
local gid_component = EntityGetFirstComponentIncludingDisabled(item, "VariableStorageComponent", "ew_global_item_id")
local gid = ComponentGetValue2(gid_component, "value_string")
local gid_component = EntityGetFirstComponent(item, "VariableStorageComponent", "ew_global_item_id")
local gid
if gid_component == nil then
gid = allocate_global_id()
EntityAddComponent2(item, "VariableStorageComponent", {
_tags = "enabled_in_world,enabled_in_hand,enabled_in_inventory,ew_global_item_id",
value_string = gid,
})
else
gid = ComponentGetValue2(gid_component, "value_string")
end
--local vel = EntityGetFirstComponentIncludingDisabled(item, "VelocityComponent")
--if vel then

View file

@ -60,17 +60,17 @@ function rpc.set_cosmetics_all(id, amulet, gem, crown)
for peer_id, player_data in pairs(ctx.players) do
if peer_id == id then
local player_entity = player_data.entity
local player_components = EntityGetAllComponents(player_entity)
local player_components = EntityGetComponent(player_entity, "SpriteComponent", "character")
if player_components ~= nil then
for _, comp in ipairs(player_components) do
if comp == nil then
goto continue
end
if ComponentGetValue2(comp, "image_file") == "data/enemies_gfx/player_amulet.xml" and amulet then
if amulet and ComponentGetValue2(comp, "image_file") == "data/enemies_gfx/player_amulet.xml" then
EntitySetComponentIsEnabled(player_entity, comp, false)
elseif ComponentGetValue2(comp, "image_file") == "data/enemies_gfx/player_amulet_gem.xml" and gem then
elseif gem and ComponentGetValue2(comp, "image_file") == "data/enemies_gfx/player_amulet_gem.xml" then
EntitySetComponentIsEnabled(player_entity, comp, false)
elseif ComponentGetValue2(comp, "image_file") == "data/enemies_gfx/player_hat2.xml" and crown then
elseif crown and ComponentGetValue2(comp, "image_file") == "data/enemies_gfx/player_hat2.xml" then
EntitySetComponentIsEnabled(player_entity, comp, false)
end
::continue::