Proobleem
Posted: Fri May 06, 2016 3:40 pm
Can someone tell me why it's not working?
Tjakka5 wrote:At line 18 you are overwriting your love.draw function you defined at line 10.
Code: Select all
gscore = 0
function love.conf(t)
t.window.width = 800
t.window.height = 600
end
function love.load()
krktr = love.graphics.newImage("krktr.png")
end
function love.draw()
love.graphics.draw(krktr, 350, 250)
love.graphics.print("Score = " + gscore, 0, 0)
end
function love.mousepressed(x, y, button, istouch)
if button == 1 then -- the primary button
gscore = gscore + 1
end
end
Code: Select all
"Score = " + gscore
Code: Select all
"Score = " .. gscore
Oh, thanks!undef wrote:
Please read the posting rules first. Help us help you.
This is not how you do string concatenation in Lua:This is how you do it:Code: Select all
"Score = " + gscore
Code: Select all
"Score = " .. gscore
I recommend reading the Lua 5.1 reference manual, which might be a bit dry at first but it's a life saver.
I also strongly recommend reading Programming in Lua 3. Edition.
While it's aimed at a newer version of Lua than LÖVE uses, it's still largely relevant.
You might think that this takes too long, and that you prefer to try stuff out and learn like that, but trust me - you will save so much time if you read (or at least skim over) them first.
You will get better much more quickly and you will know where to look stuff up when you have a problem.