How to put variable values in drawn text()

I wanted to have a “score:” indicator on the top left part of the screen, so to do so I did this (this is a simplified version of the code that I have):

function setup()
score=100
end
function draw()
text("Score: "+math.floor(score/10),30,HEIGHT-15)
fill(255, 255, 255, 255)
end

As you can see there, I made the string value based on my prior knowledge of JavaScript where you can have console.log(“Quotations " + variable + " quotations.”); And it will print (or log): Quotations (variable’s value) quotations. Obviously you can’t do that here because when I try to run my code (or in this case the example code above) it says: line 5: attempt to perform arithmetic on a string value.

Please can someone tell me how you can correctly put variable values (or simplified arithmetic equations) into drawn text form.

Thanks in advance :slight_smile:

Use … instead of +


function setup()
    score=100
end

function draw()
    fill(255, 255, 255, 255)
    text("Score: "..math.floor(score/10),50,HEIGHT-15)
end

@Paintcannon - Codea is built on Lua, so when you get stuck on basic syntax problems, just google, eg “lua join strings”

@Ignatz Lua string concatenation* :wink: