From 683839013b4c0a0b9f5863d1e7e5b467b8484f02 Mon Sep 17 00:00:00 2001 From: Isaac0-dev <62234577+Isaac0-dev@users.noreply.github.com> Date: Mon, 3 Apr 2023 15:21:44 +1000 Subject: [PATCH] fix lakitu cam duplication hopefully (#336) --- mods/lakituCam.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mods/lakituCam.lua b/mods/lakituCam.lua index 03bee7906..e1482976b 100644 --- a/mods/lakituCam.lua +++ b/mods/lakituCam.lua @@ -124,8 +124,22 @@ end local bhvPlayerLakitu = hook_behavior(nil, OBJ_LIST_DEFAULT, true, bhv_custom_lakitu_init, bhv_custom_lakitu) +-- search for a Lakitu with our global index +local function search_for_lakitu(index) + local o = obj_get_first_with_behavior_id(bhvPlayerLakitu) + while o ~= nil do + if o.oLakituOwner == index then + return o + end + o = obj_get_next_with_same_behavior_id(o) + end + return nil +end + -- spawn the local player's Lakitu when the area's sync state is valid (every time the player warps areas) local function update_lakitu() + -- if a Lakitu that we own already exists, don't spawn a new one + if search_for_lakitu(npl.globalIndex) then return end -- spawn Lakitu with our custom Lakitu behavior and the default Lakitu model; and mark it as a sync object spawn_sync_object(bhvPlayerLakitu, E_MODEL_LAKITU, 0, 0, 0, function(o) -- save the global id of the player that owns this Lakitu