Problem with post message

Hello, I’m a beginner in Defold.
I’m having trouble passing a message to player.script. I can’t figure out what I’m missing.

trigger.script

function on_message(self, message_id, message, sender)
	if message_id == TRIGGER_RESPONSE then
		if message.other_group == PLAYER then
			if message.enter then
				msg.post("main:/player/player#player", "player_in")
				print("in", message.other_id)
				--self.is_player_near = true
			else
				msg.post("main:/player/player#player", "player_out")
				print("out", message.other_id)
			end
		end
	end
end

player.script

function on_message(self, message_id, message, sender)
	if message_id == hash("player_in") then
		print("get")
		self.is_interactive = true

	elseif message_id == hash("player_out") then
		self.is_interactive = false
	end
end

The trigger is working, the issue is somewhere in the player
problem


This work fine

forge.script

function on_message(self, message_id, message, sender)
	if message_id == hash("disable") then
		go.set(".", "scale", vmath.vector3(0))  --  TEST
	end
end

player.script

function interact(self)
	print("interact")
	msg.post("main:/forge/forge#forge", "disable")
end

Can you describe the problem a bit more?
What exactly is failing?

When I’m inside a trigger, the self.is_interactive variable doesn’t become true

And, do you get any info in the logs? Are there any warnings or errors?

problem
No errors, only notifications about entering and exiting the trigger

Set a break point (or add a print(msg.url(), message_id) at the top of the player on_message function to make sure you actually get there.

1 Like

Thank you, the problem was with the wrong ID (I renamed it and forgot to fix it)