mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
remove some meaningless errors on long teleports as long teleports seem to delete the entity
This commit is contained in:
parent
7f8699c0ae
commit
f3b57bc3fd
4 changed files with 30 additions and 21 deletions
|
@ -350,8 +350,10 @@ end
|
|||
|
||||
function inventory_helper.has_inventory_changed(player_data)
|
||||
local prev_inventory = player_data.prev_inventory_hash
|
||||
|
||||
local inventory_hash = 0
|
||||
if player_data.entity == nil then
|
||||
return false
|
||||
end
|
||||
for _, item in ipairs(GameGetAllInventoryItems(player_data.entity) or {}) do
|
||||
local item_comp = EntityGetFirstComponentIncludingDisabled(item, "ItemComponent")
|
||||
local slot_x, slot_y = ComponentGetValue2(item_comp, "inventory_slot")
|
||||
|
|
|
@ -63,6 +63,9 @@ function rpc.set_cosmetics_all(id, amulet, gem, crown)
|
|||
local player_components = EntityGetAllComponents(player_entity)
|
||||
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
|
||||
EntitySetComponentIsEnabled(player_entity, comp, false)
|
||||
elseif ComponentGetValue2(comp, "image_file") == "data/enemies_gfx/player_amulet_gem.xml" and gem then
|
||||
|
@ -70,6 +73,7 @@ function rpc.set_cosmetics_all(id, amulet, gem, crown)
|
|||
elseif ComponentGetValue2(comp, "image_file") == "data/enemies_gfx/player_hat2.xml" and crown then
|
||||
EntitySetComponentIsEnabled(player_entity, comp, false)
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,6 +42,9 @@ function module.on_world_update()
|
|||
end
|
||||
|
||||
local px, py = EntityGetTransform(player_data.entity)
|
||||
if px == nil then
|
||||
return
|
||||
end
|
||||
local player_dir_x = px - ccx
|
||||
local player_dir_y = py - ccy
|
||||
local dist_sq = player_dir_x * player_dir_x + player_dir_y * player_dir_y
|
||||
|
|
|
@ -131,24 +131,24 @@ end
|
|||
|
||||
function OnPausedChanged(paused, is_wand_pickup)
|
||||
ctx.is_wand_pickup = is_wand_pickup
|
||||
local players = EntityGetWithTag("player_unit") or {}
|
||||
local players = EntityGetWithTag("player_unit") or {}
|
||||
|
||||
if (players[1]) then
|
||||
np.RegisterPlayerEntityId(players[1])
|
||||
--local inventory_gui = EntityGetFirstComponentIncludingDisabled(players[1], "InventoryGuiComponent")
|
||||
local controls_component = EntityGetFirstComponentIncludingDisabled(players[1], "ControlsComponent")
|
||||
if (paused) then
|
||||
--EntitySetComponentIsEnabled(players[1], inventory_gui, false)
|
||||
np.EnableInventoryGuiUpdate(false)
|
||||
np.EnablePlayerItemPickUpper(false)
|
||||
ComponentSetValue2(controls_component, "enabled", false)
|
||||
else
|
||||
--EntitySetComponentIsEnabled(players[1], inventory_gui, true)
|
||||
np.EnableInventoryGuiUpdate(true)
|
||||
np.EnablePlayerItemPickUpper(true)
|
||||
ComponentSetValue2(controls_component, "enabled", true)
|
||||
end
|
||||
end
|
||||
if (players[1]) then
|
||||
np.RegisterPlayerEntityId(players[1])
|
||||
--local inventory_gui = EntityGetFirstComponentIncludingDisabled(players[1], "InventoryGuiComponent")
|
||||
local controls_component = EntityGetFirstComponentIncludingDisabled(players[1], "ControlsComponent")
|
||||
if (paused) then
|
||||
--EntitySetComponentIsEnabled(players[1], inventory_gui, false)
|
||||
np.EnableInventoryGuiUpdate(false)
|
||||
np.EnablePlayerItemPickUpper(false)
|
||||
ComponentSetValue2(controls_component, "enabled", false)
|
||||
else
|
||||
--EntitySetComponentIsEnabled(players[1], inventory_gui, true)
|
||||
np.EnableInventoryGuiUpdate(true)
|
||||
np.EnablePlayerItemPickUpper(true)
|
||||
ComponentSetValue2(controls_component, "enabled", true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function OnWorldInitialized() -- This is called once the game world is initialized. Doesn't ensure any world chunks actually exist. Use OnPlayerSpawned to ensure the chunks around player have been loaded or created.
|
||||
|
@ -204,7 +204,7 @@ function OnPlayerSpawned( player_entity ) -- This runs when player entity has be
|
|||
end
|
||||
|
||||
local function on_world_pre_update_inner()
|
||||
if ctx.my_player == nil then return end
|
||||
if ctx.my_player == nil or ctx.my_player.entity == nil then return end
|
||||
|
||||
GlobalsSetValue("ew_player_rng", tostring(GameGetFrameNum()))
|
||||
|
||||
|
@ -260,7 +260,7 @@ function OnWorldPreUpdate() -- This is called every time the game is about to st
|
|||
end
|
||||
|
||||
local function on_world_post_update_inner()
|
||||
if ctx.my_player == nil then return end
|
||||
if ctx.my_player == nil or ctx.my_player.entity == nil then return end
|
||||
|
||||
if not ctx.run_ended then
|
||||
ctx.hook.on_world_update_post()
|
||||
|
@ -285,7 +285,7 @@ local function on_world_post_update_inner()
|
|||
end
|
||||
|
||||
function OnWorldPostUpdate() -- This is called every time the game has finished updating the world
|
||||
util.tpcall(on_world_post_update_inner)
|
||||
util.tpcall(on_world_post_update_inner)
|
||||
ctx.events = {}
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue