Jump to content

Crash game after changing map


TEPA6ANT
 Share

Recommended Posts

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?

Link to comment
Share on other sites

Problem is solved.
Delete:

Script.objects={}

Add: 

self.objects={}

in Script:Start()

Now the game does not crash.

But. I want to know.
Are there any other options to find out that the object is a light, except what I wrote (terribly) in the code?

if entity:GetKeyValue("name") ~= ("Point Light 2" or "Spot Light 2") then
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...