mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
add some nil checks
This commit is contained in:
parent
27fab90db7
commit
09e861c6dc
4 changed files with 25 additions and 9 deletions
|
@ -129,9 +129,15 @@ function end_fight.on_world_update()
|
|||
local collision = EntityGetFirstComponentIncludingDisabled(entity, "PlayerCollisionComponent")
|
||||
local suck = EntityGetFirstComponentIncludingDisabled(entity, "MaterialSuckerComponent")
|
||||
local gui = EntityGetFirstComponentIncludingDisabled(entity, "InventoryGuiComponent")
|
||||
EntitySetComponentIsEnabled(entity, gui, false)
|
||||
EntitySetComponentIsEnabled(entity, suck, false)
|
||||
EntitySetComponentIsEnabled(entity, collision, false)
|
||||
if gui ~= nil then
|
||||
EntitySetComponentIsEnabled(entity, gui, false)
|
||||
end
|
||||
if suck ~= nil then
|
||||
EntitySetComponentIsEnabled(entity, suck, false)
|
||||
end
|
||||
if collision ~= nil then
|
||||
EntitySetComponentIsEnabled(entity, collision, false)
|
||||
end
|
||||
for _, child in ipairs(EntityGetAllChildren(entity) or {}) do
|
||||
EntityKill(child)
|
||||
end
|
||||
|
|
|
@ -246,7 +246,9 @@ function spectate.on_world_update()
|
|||
if inv_spec ~= nil then
|
||||
ComponentSetValue2(inv_spec, "mActive", false)
|
||||
end
|
||||
ComponentSetValue2(inv_me, "mActive", false)
|
||||
if inv_me ~= nil then
|
||||
ComponentSetValue2(inv_me, "mActive", false)
|
||||
end
|
||||
elseif GameGetFrameNum() % 10 == 0 then
|
||||
for peer_id, data in pairs(ctx.players) do
|
||||
if peer_id ~= ctx.my_id then
|
||||
|
|
|
@ -73,7 +73,9 @@ end
|
|||
function rpc.send_money(money)
|
||||
local entity = ctx.rpc_player_data.entity
|
||||
local wallet = EntityGetFirstComponentIncludingDisabled(entity, "WalletComponent")
|
||||
ComponentSetValue2(wallet, "money", money)
|
||||
if wallet ~= nil then
|
||||
ComponentSetValue2(wallet, "money", money)
|
||||
end
|
||||
end
|
||||
|
||||
local last_spectate
|
||||
|
@ -128,7 +130,9 @@ function module.on_world_update()
|
|||
end
|
||||
if GameGetFrameNum() % 60 == 47 then
|
||||
local wallet = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "WalletComponent")
|
||||
rpc.send_money(ComponentGetValue2(wallet, "money"))
|
||||
if wallet ~= nil then
|
||||
rpc.send_money(ComponentGetValue2(wallet, "money"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -307,12 +307,16 @@ local function on_world_pre_update_inner()
|
|||
|
||||
if GameGetFrameNum() % 4 == 0 then
|
||||
local x, y = EntityGetTransform(ctx.my_player.entity)
|
||||
change_homing(x, y)
|
||||
if x ~= nil then
|
||||
change_homing(x, y)
|
||||
end
|
||||
elseif GameGetFrameNum() % 4 == 1 then
|
||||
local x, y = EntityGetTransform(ctx.my_player.entity)
|
||||
local cx, cy = GameGetCameraPos()
|
||||
if math.abs(x - cx) > 256 or math.abs(y - cy) > 256 then
|
||||
change_homing(cx, cy)
|
||||
if x ~= nil and cx ~= nil then
|
||||
if math.abs(x - cx) > 256 or math.abs(y - cy) > 256 then
|
||||
change_homing(cx, cy)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue