Hi! I’m new to lua and Defold and faced some problem.
why self.steps is getting a nil value in function on_message? Even if it was initialized in function init?
function init(self)
self.steps = 1
end
function on_message(self, message_id, message, sender)
print(self.steps)
if message_id == hash("touch") then
print('is ok')
print(steps)
self.steps = self.steps + message.steps
print('is ok11')
local stepsnode = gui.get_node("steps")
gui.set_text(stepsnode, "SCORE: " .. self.steps)
end
end
Thanks!