Error loading collections

Trying to load a lose menu but got this error
ERROR:GAMESYS: The collection /lose_ending/lose_ending.collectionc could not be loaded.
ERROR:GAMESYS: The collection /lose_ending/lose_ending.collectionc could not be unloaded since it was never loaded. Message ‘unload’ sent from loader:/loader_go#loader to loader:/loader_go#lose_ending.
ERROR:GAMEOBJECT: The collection ‘lose_ending’ could not be created since there is already a socket with the same name.

Not sure why its not working here is the loader script

elseif message_id == hash("lose_ending") then
		msg.post(self.current_collection, "unload")
		msg.post("#lose_ending", "load")
		self.current_collection = "#lose_ending"
	end
end

the load menu gui script is here

function init(self)
	msg.post(".", "acquire_input_focus")
end

function final(self)
	msg.post(".", "release_input_focus")
end

function on_input(self, action_id, action)
	if(action_id == hash("touch") and action.released == true) then
		if gui.pick_node(gui.get_node("mainmenu"), action.x, action.y) then
			msg.post("loader:/loader_go#loader", "exit_screen")
		end
	end
end

and this is actioned by

	elseif self.strike < 49 then
		msg.post("/healthbar#healthbar_sprite", "play_animation", {id = hash("empty_health")})
		print("max strikes")
		msg.post("loader:/loader_go#loader", "lose_ending")
		print("ending sent")
	end
end

Do you happen to have two collections with the same name (which becomes the socket in the url)?

image

no, only loader, lose_ending, menu, win_ending

It looks like you are unloading the same collection twice or something like that.

I recommend that you study this example: Proxy

This condition here may be tru a few times. you don’t have any protection against it.

Then you get this messages here

Firs message works fine. It starts the unloading process, and loading of the lose_ending collection proxy.

But second message tries immidiatly unload and load it again, that’s why error happens.

Make sure you send the following message only once:

msg.post(“loader:/loader_go#loader”, “lose_ending”)

3 Likes

its only being sent once, and every other code is the same

the rest of my loader code is the exact same, no where is the message being sent twice, how do i stop it from immediately unloading and loading?

function on_message(self, message_id, message, sender)
	if message_id == hash("start") then
		msg.post(self.current_collection, "unload")
		msg.post("#main", "load")
		self.current_collection = "#main"
	elseif message_id == hash("controls") then
		msg.post(self.current_collection, "unload")
		msg.post("#controls", "load")
		self.current_collection = "#controls"
	elseif message_id == hash("proxy_loaded") then
		msg.post(sender, "enable")
	elseif message_id == hash("exit_screen") then
		msg.post(self.current_collection, "unload")
		msg.post("#mainmenu", "load")
		self.current_collection = "#mainmenu"
	elseif message_id == hash("win_ending") then
		msg.post(self.current_collection, "unload")
		msg.post("#win_ending", "load")
		self.current_collection = "#win_ending"
	elseif message_id == hash("lose_ending") then
		msg.post(self.current_collection, "unload")
		msg.post("#lose_ending", "load")
		self.current_collection = "#lose_ending"
	end
end

Add a print or set a breakpoint to verify that this is indeed correct.

how do i do that?

Take a look at the debugging manual: Debugging in Defold

If that doesn’t help then share the entire project here as a zip file for others to take a look at.

how do i make it a zip after i bundle??

DEBUG:SCRIPT: lose ending load
had this debug message

If we are to help we need to project source code, not the bundled game.

how do i give you that

Find you project folder (the one with game.project in it) and zip all files and folder (excluding the build folder and the folder named .internal).

Windows: Zip and unzip files - Microsoft Support.
macOS: Zip and unzip files and folders on Mac - Apple Support.

Once you have a zipfile, you can drag and drop it here when you write an answer to include it in your post.

neap2.zip (3.2 MB)

try this

That’s the bundle of your game (the thing you would ship to players). The project folder is the one you open in the editor with your scripts and collections.

1 Like

the file is too big apparently

How big is it? Can you share a Dropbox or Google Drive download link perhaps?