No idea what's wrong

Hi, I just made this code real quick, but it doesn’t work, and I honestly have no idea why.

function setup()
    Timer=0
end
function draw()
    background(100)
    fontSize(100)
    fill(255,0,0)
    text("Dragon Died: "..Timer "Seconds Ago",512,500)
    text("Dragon Respawning In: "..360-Timer,512,300)
    fill1,fill2,fill3=math.random(0,255),math.random(0,255),math.random(0,255)
    if TimerStart==true then
        Timer=Timer+0.016
    end
    if Timer>360 then
        fill(fill1,fill2,fill3)
        rect(0,0,1024,768)
    end
    if Timer>480 then
        TimerStart=false
        Timer=0
    end
end
function touched(t)
    if t.state==BEGAN then
        TimerStart=true
    end
end

Codea tells me Timer has a nil value, although I gave it the value 0 (Any help on shortening the code would be appreciated too).

You are missing a comma after the word Timer in line 8

I wouldn’t worry about shortening the code just yet. So far, it looks fine to me.

@Ignatz I’m just gonna act like this never happened =))

@wildcat_JK Actually, you’re missing the … after Timer, see below. Also, reduce the fontSize to about 25 for now.

    text("Dragon Died: "..Timer.."Seconds Ago",512,500)

@wildcat_JK You should also look into using the string.format command. Try the code below instead of your 2 text statements.

    text(string.format("Dragon Died: %5.1f  Seconds Ago",Timer),512,500)   
    text(string.format("Dragon Respawning In: %5.1f",360-Timer),512,300)

@dave1707 Where does the %5.1f stand for?

Google “lua string.format”

http://www.gammon.com.au/scripts/doc.php?lua=string.format

@wildcat_JK There are a lot of options for string.format, so it’s better to see the link @Ignatz shared. But to answer your question, %5.1f means the result will be 5 characters wide with 1 digit past the decimal point. The f means to use a floating point number.

@dave1707 ah, ok. Thanks for explaining that.