I have a simple script that I usually test with and has been working ever since I’ve had Corona. But now it’s not! And no errors show in the terminal.
module(..., package.seeall)
function new()
local a = display.newGroup()
score = 0
local scoreText = display.newText("0", display.contentWidth/2, 25, native.systemFontBold, 14 )
scoreText:setTextColor( 255, 0, 0 )
a:insert(scoreText)
local b = display.newRect( 100, 100, 100, 100 )
b:setFillColor( 255, 0, 0 )
a:insert(b)
local onScore = function( event )
if event.phase == "began" then
score = score + 50
scoreText.text = tostring(scoreText)
end
end
b:addEventListener("touch", onScore)
return a
end
Usually, the results would simply add the score but instead on the simulator, it’s showing:
table: 0x1014878f0
table: 0x10c302310
basically random hex numbers. I have to restart the application every time, then I press, another random hex. What is going on here? This used to work! [import]uid: 114389 topic_id: 30582 reply_id: 330582[/import]
“scoretext” is your display object… a table, as many things in Lua technically are. “score” is the value of this, which you can convert to a string “0”, although you don’t really need to in this case of changing the text object’s appearance on screen.