Why am I getting nil value even though I initialize a variable? (SOLVED)

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!

1 Like

Is message.steps the one that is nil?

Try to pprint(message)

1 Like

it was just a usual carelessness.
msg.post was sending to step, not steps.

2 Likes