Error
Posted: Tue Apr 30, 2013 7:48 pm
I'm getting an error that says:
--------------------------------------------------------------------------------------------------------
grapics.lua:1265: bad argument #3 to 'print1' (number expected, got string)
Traceback
[C]: in function 'print1'
graphics.lua:1265: in function 'print'
menu.lua:12: in function 'button_draw'
main.lua:30: in function 'draw'
[C]: in function 'xpcall'
--------------------------------------------------------------------------------------------------------
I'll post my code for menu.lua and main.lua here:
main.lua
--------------------------------------------------------------------------------------------------------
require "player"
require "map"
require "menu"
function love.load()
medium = love.graphics.newFont(45)
love.graphics.setBackgroundColor(0,255,0)
base = 550
gamestate = "menu"
-- Buttons
button_spawn(10,50,"Start")
-- Loading
player.load()
end
function love.update(dt)
UPDATE(dt)
MAP_UPDATE()
end
function love.draw()
DRAW()
if gamestate == "menu" then
button_draw()
end
end
function love.keypressed(key, unicode)
end
function love.keyreleased(key)
end
--------------------------------------------------------------------------------------------------------
and menu.lua
--------------------------------------------------------------------------------------------------------
button = {}
function button_spawn(x,y,text)
table.insert(button, {x = x,y = y,text = text})
end
function button_draw()
for i,v in ipairs(button) do
love.graphics.setColor(0,0,0)
love.graphics.setFont(medium)
love.graphics.print(v.x,v.y,v.text)
end
end
--------------------------------------------------------------------------------------------------------
Everything was working until I made/tried to make a table.
I don't know what's wrong and if you do please help me.
Thanks
--------------------------------------------------------------------------------------------------------
grapics.lua:1265: bad argument #3 to 'print1' (number expected, got string)
Traceback
[C]: in function 'print1'
graphics.lua:1265: in function 'print'
menu.lua:12: in function 'button_draw'
main.lua:30: in function 'draw'
[C]: in function 'xpcall'
--------------------------------------------------------------------------------------------------------
I'll post my code for menu.lua and main.lua here:
main.lua
--------------------------------------------------------------------------------------------------------
require "player"
require "map"
require "menu"
function love.load()
medium = love.graphics.newFont(45)
love.graphics.setBackgroundColor(0,255,0)
base = 550
gamestate = "menu"
-- Buttons
button_spawn(10,50,"Start")
-- Loading
player.load()
end
function love.update(dt)
UPDATE(dt)
MAP_UPDATE()
end
function love.draw()
DRAW()
if gamestate == "menu" then
button_draw()
end
end
function love.keypressed(key, unicode)
end
function love.keyreleased(key)
end
--------------------------------------------------------------------------------------------------------
and menu.lua
--------------------------------------------------------------------------------------------------------
button = {}
function button_spawn(x,y,text)
table.insert(button, {x = x,y = y,text = text})
end
function button_draw()
for i,v in ipairs(button) do
love.graphics.setColor(0,0,0)
love.graphics.setFont(medium)
love.graphics.print(v.x,v.y,v.text)
end
end
--------------------------------------------------------------------------------------------------------
Everything was working until I made/tried to make a table.
I don't know what's wrong and if you do please help me.
Thanks