Page 1 of 1

A weird error I cant fix

Posted: Sat Jun 08, 2013 9:54 pm
by cybercircuit
Heres my code:


require "player"
require "zombie"
require "inventory"
require "items"

menuTexture = love.graphics.newImage("menuBackground.png")
rt = love.graphics.newImage("spawn.png")
gs = "menu"


buttonImage = love.graphics.newImage("buttonTexture.png")

registerItems()

function switchRoom(texture)

rt = texture

end

function love.update()

if gs == "menu" then

if (love.mouse.getX() > 270 and love.mouse.getX() < 500) and (love.mouse.getY() > 300 and love.mouse.getY() < 391) then

if love.mouse.isDown("l") == true then

gs = "chooseGame"

end


end

end

end




function renderGame()

love.graphics.draw(rt)

updateZombies()
updatePlayer()
updateInventory()

end



function love.draw()


if gs == "playing" then


renderGame()

else

if gs == "menu" then
love.graphics.draw(menuTexture)
love.graphics.draw(buttonImage, 250, 300)
love.graphics.setColor(0,0,0)
love.graphics.print("Play", 300, 310, 0, 5)
love.graphics.setColor(255,255,255)

end
if gs == "chooseGame" then

love.draw(buttonImage, 250, 300)

end
end
end


Heres my error:

Error: main.lua:77: stack overflow
stack traceback:
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
...
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
main.lua:77: in function 'draw'
[string "boot.lua"]:410: in function <[string "boot.lua"]:373>
[C]: in function 'xpcall'


I would like to say I dont know whats causing the error AND there is no line 77, help?

Re: A weird error I cant fix

Posted: Sat Jun 08, 2013 10:13 pm
by Plu
Could you maybe upload a .love version of your entire source? I don't think this is enough to find the error.


(If it helps, this looks like a very clear sign of infinite recursion, so I'm pretty sure that the problem is that your love.draw function is calling itself somewhere in it, but since I don't have the definitions of the other functions, I cannot see where)

Re: A weird error I cant fix

Posted: Sat Jun 08, 2013 10:19 pm
by Joemag
In your love.draw you call:

Code: Select all

love.draw(buttonImage, 250, 300)
This should be

Code: Select all

love.graphics.draw(buttonImage, 250, 300)

Re: A weird error I cant fix

Posted: Sat Jun 08, 2013 10:20 pm
by cybercircuit
THANK YOU!!!!

Re: A weird error I cant fix

Posted: Sat Jun 08, 2013 10:22 pm
by Plu
Can't believe I missed that :P

Re: A weird error I cant fix

Posted: Sun Jun 09, 2013 1:11 am
by Jasoco
Please use the Code tags when posting code or errors. It makes it easier to read and saves a lot of scrolling time.