Jump to content

LevelChange Problems


KTyJLXy
 Share

Recommended Posts

Hi guys. Yep, that's me again. I've got windows critical error (and it says nothing? like bla-bla programm should be closed) on attempt to change level.

Lua debug says nothing on this account.

 

Here's the app code

 


--This function will be called once when the program starts
function App:Start()

--Initialize Steamworks (optional)
Steamworks:Initialize()

--Set the application title
self.title="DungeonScrolls"

--Create a window
self.window=Window:Create(self.title,0,0,1366,768,Window.Titlebar+Window.Center+8)
self.window:HideMouse()

--Create the graphics context
self.context=Context:Create(self.window,0)
if self.context==nil then return false end

self.menumusic=Sound:Load("Sound/Music/Main theme.wav")
if self.menumusic~=nil then
	self.musicsource = Source:Create()
	self.musicsource:SetSound(self.menumusic)
	self.menumusic:Release()
	self.menumusic=nil
	self.musicsource:SetVolume(1)
    self.musicsource:SetLoopMode(true)
	self.musicsource:Play()
end

--Create settings table and add defaults
self.settings={}
self.settings.vsync=True

--Create a world
self.world=World:Create()

--Load a map
--local mapfile = System:GetProperty("map","Maps/start.map")
self.mapfile = "Maps/start.map"
if Map:Load(self.mapfile)==false then return false end
self.mapfile = ""

return true
end

function App:SwitchLevel(name)
self.mapfile = name
end

function App:LevelCheck()
if self.mapfile ~= "" then
self.world:Release()
self.world = World:Create()
Map:Load(self.mapfile)
self.mapfile = ""
end
end


--This is our main program loop and will be called continuously until the program ends
function App:Loop()

self:LevelCheck()

--If window has been closed, end the program
if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end

--Update the app timing
Time:Update()

--Update the world
self.world:Update()

--Render the world
self.world:Render()

--Render statistics
self.context:SetBlendMode(Blend.Alpha)
if DEBUG then
	self.context:SetColor(1,0,0,1)
	self.context:DrawText("Debug Mode",2,2)
	self.context:SetColor(1,1,1,1)
	self.context:DrawStats(2,22)
	self.context:SetBlendMode(Blend.Solid)
else
	--Toggle statistics on and off
	if (self.window:KeyHit(Key.F11)) then self.showstats = not self.showstats end
	if self.showstats then
		self.context:SetColor(1,1,1,1)
		self.context:DrawText("FPS: "..Math:Round(Time:UPS()),2,2)
	end
end

--Refresh the screen
self.context:Sync(false)

--Returning true tells the main program to keep looping
return true
end

 

And here's the trigger code

 


Script.entered = false
Script.exited = false
Script.hadCollision = false

Script.Map = "" --path

function Script:UpdatePhysics()
   if self.entered then
       if self.hadCollision == false then
           if self.exited == false then
               self.exited = true
               self.component:CallOutputs("OnExit")
               self.entered = false
           end
       end
   end

   self.hadCollision = false
end

function Script:Collision(entity, position, normal, speed)
   self.hadCollision = true

   self.component:CallOutputs("OnCollide")

   if self.entered == false then
       self.component:CallOutputs("OnEnter")
	App:SwitchLevel(self.Map)
       self.entered = true
       self.exited = false
   end
end

Link to comment
Share on other sites

Just a note if you Clear() the world you don't need to create another one. You are reusing the current world so you can comment that line out. Other than that I don't know what to tell you. This all works for me. I just tested the below and it works perfectly.

 

function App:ChangeLevel(newLevel)
self.newLevel = newLevel
end

function App:ShouldChangeLevel()
if self.newLevel ~= "" then
self.world:Clear()
Map:Load(self.newLevel)
self.newLevel = ""
end
end

--This is our main program loop and will be called continuously until the program ends
function App:Loop()

self:ShouldChangeLevel()

-- all the other stuff I just didn't want to paste here
end

Link to comment
Share on other sites

I would if I were you. I would make a small test project just for this and include that in the bug report as well. List out your specs and make sure you have the most current version (I'm opted into the beta as well).

 

Yeah, what you experience with the lag is because all the entities in your other scene are still there. They weren't removed because your world wasn't cleared. It's a huge memory leak to do that.

Link to comment
Share on other sites

I've opted into beta and have created project just for testing.

I've got following error now, instead of windows critical:

Object reference count error.

And output like

 

 

Map file = maps/second.map

Deleting material "e:/leadwerks projects/projectfortests/materials/developer/greengrid.mat"

Deleting shader "E:/Leadwerks projects/Changetest/shaders/model/diffuse.shader"

Deleting texture "e:/leadwerks projects/projectfortests/materials/developer/greengrid.tex"

Deleting texture "E:/Leadwerks projects/Changetest/Materials/Common/bfn.tex"

Deleting shader "E:/Leadwerks projects/Changetest/Shaders/Lighting/ambientlight.shader"

Setting breakpad minidump AppID = 251810

Steam_SetMinidumpSteamID: Caching Steam ID: 76561197981090266 [API loaded no]

Process Complete.

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...