Please help. I’ve been trying to get this to work for two days. I am editing the code for the snake game and trying to make a scoreboard. When the snake finds tiles 2/3 it dies. When it finds tiles 5/6/8 I want the score to be updated.
I don’t see any obvious problem. Did you try some print debugging or the built in debugger to check if the main.gui_script actually receives the “add_score” message?
I tried debugging and it turns out that the script isn’t receiving the command. The score gets updated in the snake.script, but the message isn’t sent to the main.gui_script
The script expects that there is a component with id main on the same game object as the snake.script. I’m guessing that the main.gui isn’t attached to this game object?
Ok, that looks right. The snake.scipt and the main.gui are both attached to the snake game object. The message really should be sent to the main.gui and the script. Can you pleas zip your project and share it here?
I had included this code in the main.gui_script file:
function on_message(self, message_id, message, sender)
if message_id == hash(“game_over”) then
msg.post(“gameover”, “enable”)
end
end
I understand that it’s wrong. I was trying to make a game over text appear when the snake collides with itself. When I removed this code, the point system worked.