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).
@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.