money = 10
function love.load()
fontImg = love.graphics.newImage("assets/font.png")
font = love.graphics.newImageFont( fontImg, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&''*#=[]")
Money = love.graphics.newText(font, "Money:" ???)
function love.draw()
love.graphics.draw(Money, 850, 60)
end
i left out love.update since i dont need it in this situation but how to i make it so the text says "Money: ...Value" or 10 as i set it. In an old engine i used i could just do "Money:" ..money.value.."" but this does not work?
money = 10
function love.draw()
love.graphics.print(money, 850, 60)
end
If you want to use them though, then you can use either the concatenation operator (..) or the string.format function, like so:
(Uncomment the line you want to test/see how it works)
money = 10
function love.load()
fontImg = love.graphics.newImage("assets/font.png")
font = love.graphics.newImageFont( fontImg, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&''*#=[]")
Money = love.graphics.newText(font, "Money:" .. money) -- nice and simple; the conversion from number to string happens implicitly (automatically)
-- Money = love.graphics.newText(font, string.format("Money: %d",money)) -- format replaces the %d token with a number argument, that we gave it though the money argument.
-- Money = love.graphics.newText(font, ("Money: %d"):format(money)) -- this works the same as the one above, the string object gets passed to format as its first parameter.
end
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
money = 10
function love.draw()
love.graphics.print(money, 850, 60)
end
If you want to use them though, then you can use either the concatenation operator (..) or the string.format function, like so:
(Uncomment the line you want to test/see how it works)
money = 10
function love.load()
fontImg = love.graphics.newImage("assets/font.png")
font = love.graphics.newImageFont( fontImg, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&''*#=[]")
Money = love.graphics.newText(font, "Money:" .. money) -- nice and simple; the conversion from number to string happens implicitly (automatically)
-- Money = love.graphics.newText(font, string.format("Money: %d",money)) -- format replaces the %d token with a number argument, that we gave it though the money argument.
-- Money = love.graphics.newText(font, ("Money: %d"):format(money)) -- this works the same as the one above, the string object gets passed to format as its first parameter.
end