Compilation failure near 'msg' (SOLVED)

/main/main.script
Line 30: Compilation failed: syntax error near ‘msg’
Does anyone know how to fix this, first time using defold so no too sure how to?

Hi and welcome. It means that you’ve made some sort of mistake on line 30 of main.script. Post your script here and we’ll help. Put ``` on the line before and after, and it will be formatted nicely.

msg.post("#title_proxy", "load")

That looks fine on the face of it. Would be good to see more of the script, it’s possible that the end of the previous line is an issue. If the file is small just post the whole thing, otherwise just the function that is causing an issue.

function init(self)
	msg.post(".","acquire_input_focus")
	self.worms_alive = -1
	self.delay = 0
	-- Show the title screen when the game is loaded
	msg.post("#title_proxy", "load")
	self.current_collection = "#title_proxy"
end

function final(self)
	--When the title screen is finished with, it is removed from focus
	msg.post(".", "release_input_focus")
end



function on_message(self, message_id, message, sender)
	--Show the collection once loaded into memory
	if message_id == hash("proxy_loaded") then
		msg.post(sender, "enable")
		if self.worms_alive > 0 then
			-- Code for spawning player to be added later
			-- Code for spawning food to be added later
		end
		
		-- Load the correct collection when a message is recieved
	elseif message_id == hash("show title screen") then
		-- Title screen
		msg,post(self.current_collection, "unload")
		```
		msg.post("#title_proxy", "load")
		```
		self.current_collection = "#title_proxy"

	elseif message_id == hash("1up") then
		-- 1 player
		msg,post(self.current_collection, "unload")
		msg.post("#game_proxy", "load")
		self.current_collection = "#game_proxy"
		self.worms_alive = 1
	
	elseif message_id == hash("2up") then
		-- 2 player
		msg.post(self.current_collection, "unload")
		msg.post("#game_proxy", "load")
		self.current_collection = "#game_proxy"
		self.worms_alive = 2
	end
end

Hi there,

you need to fix this typo (twice in the script):

4 Likes

Of course it was something so incredibly simple, thanks for the help with this

2 Likes