function love.update()
mousex, mousey = love.mouse.getPosition()
if love.mouse.isDown("r") then
love.graphics.print(mousex)
end
end
The code is supposed to assign the mouse's x position to the variable mousex, and print its value when the RMB is held. It returns an error when I right-click: graphics.lua:1: bad argument #2 to 'print1' (number expected, got no value)
what do?
function love.update()
mousex, mousey = love.mouse.getPosition()
if love.mouse.isDown("r") then
love.graphics.print(mousex)
end
end
The code is supposed to assign the mouse's x position to the variable mousex, and print its value when the RMB is held. It returns an error when I right-click: graphics.lua:1: bad argument #2 to 'print1' (number expected, got no value)
what do?
1. Don't draw in love.update(), even if your function call was correct, it won't print it if you do the love.graphics.print in update. Unless you meant print(), which goes to console. print() works anywhere AFTER LOVE.LOAD() IS CALLED.
2. love.graphics.print takes at least 3 arguments: string, x, y.
Last edited by TechnoCat on Wed Nov 02, 2011 3:03 am, edited 6 times in total.
Your error is simple: You're not allowed to use drawing functions anywhere except in love.draw(). After that, you can't forget to have coordinates for your printed text (they're the two parameters after the text you want to show).
EDIT) TechnoCat beat me to it. XP
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit! Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.