My game crashes after changing map. I found the problem, but I don't know how to solve it.
I made special zones that hide all objects in it if there is no special object in the zone (e.g. player). And show again if there is a special object in the zone.
room.lua
import "Scripts/Functions/ROOM_AABB.lua"
Script.uniq=false --bool "No typical"
Script.Special="" --string "SPECIAL commands"
--Disable,Pause,Enable
Script.state="Disable"
Script.hiden = false
Script.objects={}
function Script:UpdateRoom()
local moi_raion, spec = OBJ_inroom(self.entity,scriptOnly)
local index, entity
for index,entity in pairs(moi_raion) do
if entity:GetKeyValue("Camera")~="69" then
if spec then
local jndex,entity_obj
for jndex,entity_obj in pairs(self.objects) do
entity_obj:SetKeyValue("World_Status","")
entity_obj:Show()
end
self.objects={}
else
entity:SetKeyValue("World_Status","DE")
entity:Hide()
table.insert(self.objects,entity)
end
end
end
end
function Script:Start()
self.entity:SetKeyValue("Room",self.Special)
end
function Script:UpdateWorld()
end
function Script:UpdatePhysics()
self:UpdateRoom()
end
ROOM_AABB.lua
RoomInAABBDoCallbackTable = nil
GetEntityNeighborsScriptedOnly=false
Special_OBJ=false
function GetSosedR(entity,extra)
--System:Print("See "..entity:GetKeyValue("Special"))
if entity:GetKeyValue("name") ~= ("Point Light 2" or "Spot Light 2") then
if entity:GetKeyValue("Special")~= ("" or nil) then
Special_OBJ=true
end
table.insert(RoomInAABBDoCallbackTable,entity)
end
end
function OBJ_inroom(entity,scriptOnly)
Special_OBJ=false
local result_table
local special
local position = entity:GetPosition(true)
local localaabb = entity:GetAABB(Entity.LocalAABB)
local aabb = entity:GetAABB(Entity.RecursiveAABB)
local temp = GetEntityNeighborsScriptedOnly
GetEntityNeighborsScriptedOnly=scriptOnly
aabb:Update()
local table = RoomInAABBDoCallbackTable
RoomInAABBDoCallbackTable = {}
if entity.world then
entity.world:ForEachEntityInAABBDo(aabb,"GetSosedR",entity)
result_table = RoomInAABBDoCallbackTable
special = Special_OBJ
RoomInAABBDoCallbackTable = table
GetEntityNeighborsScriptedOnly = temp
end
return result_table, special
end
The game crashes only if there are these zones on the next and on the previous map.
I think that after loading next map, it does not remove hidden objects.
How to remove them?