Hi!
I’m in the middle of making my 2D game and I just succeeded in making the player’s score appear on the screen. The problem I’m having is although everything works just fine (I think) I still get a couple of errors when I grab a cheezedoodle (thats what the player has to collect to gain points)
The code in ‘main.gui_script’ currently looks like this:
function init(self)
self.score = 0
self.score_node = gui.get_node("score")
end
function on_message(self, message_id, message, sender)
--Debug-code to make sure we enter the function at all
print("ON_MESSAGE CONFIRMED")
if message_id == hash("add_score") then
--Debug-code to make sure we enter the if-statement properly
print("IF CONFIRMED")
self.score = self.score + message.amount
gui.set_text(self.score_node, tostring(self.score))
gui.animate(self.score_node)
end
end
And I get these errors as soon as I grab 1 cheezedoodle:
DEBUG:SCRIPT: SCORE ADDED
DEBUG:SCRIPT: IF CONFIRMED
ERROR:SCRIPT: main/main.gui_script:24: bad argument #2 to ‘animate’ (string expected, got no value)
stack traceback:
[C]: in function 'animate’
main/main.gui_script:24: in function <main/main.gui_script:15>
ERROR:GAMESYS: Error when dispatching message to gui scene: -2. Message ‘add_score’ sent from main:/instance1#script to main:/main#gui.
It’s not interfering with the actual counting and displaying of the points from what I see, I just want to understand what they are saying. I have yet to learn how interpret errors such as these despite being able to program a little bit in C++, and any explanation at all would be highly appreciated!