Problem loading a new level from a proxy

Hi everyone I am back again asking another question. I have some levels that I added to my game. I set up collection proxies and have the bootstrap pointing to a loader script on startup. I’m able to load level0 on startup, and then level1 after beating level0. But when I try to load into level2 I get this:

I’m not sure what the problem is because I use the unload function on level1 before loading into level2. If there’s something I am missing where resources have to be cleared a different way, please let me know!

(The first error message makes me think I accidentally named the level2 collection as “level1” instead but I know for a fact I changed the collection name and still get that error message)

Can you share the code you use to load and unload your collection proxies?

Yes sure, here is the loader script:


local function load_level0(self)
	msg.post("#level0", "load")
	msg.post("#level0", "enable")

end

local function unload_level0(self)
	msg.post("#level0","unload")
end

local function load_level1(self)
	msg.post("#level1", "load")
	msg.post("#level1", "enable")

end

local function unload_level1(self)
	msg.post("#level1","unload")
end

local function load_level2(self)
	msg.post("#level2", "load")
	msg.post("#level2", "enable")

end


local function unload_level2(self)
	msg.post("#level2","unload")
end

function init(self)
	msg.post(".", "acquire_input_focus")
	load_level0(self)
end
function on_message(self, message_id, message, sender)
	--comes from the player script
	if message_id == hash("load_level1") then
		unload_level0(self)
		load_level1(self)
	end
	if message_id == hash("load_level2") then
		unload_level1(self)
		load_level2(self)
	end
end

and here is where I call those functions in the player script after hitting a loading zone trigger:

if message_id == hash("trigger_response") then
		if message.enter then
			--handles loading zone trigger
			if message.other_id == hash("/level0") then
				print("Level 1 needs to be loaded",message.other_id)
				msg.post("loader:/go#loader", "load_level1")
			end
			if message.other_id == hash("/level1") then
				print("level 2 needs to be loaded",message.other_id)
				msg.post("loader:/go#loader", "load_level2")
			end

Okay funny story, I posted this last night and was getting those error messages but now when I ran it today there are no issues. I didn’t change any of the code so I’m not sure why those were being thrown but at least it works now!

You’re not waiting for the proxy_loaded message before you enable the collection! Take a look at this example: Proxy

2 Likes