A weird error I cant fix

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
cybercircuit
Prole
Posts: 16
Joined: Mon May 20, 2013 7:39 pm

A weird error I cant fix

Post 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?
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: A weird error I cant fix

Post 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)
Joemag
Prole
Posts: 24
Joined: Sun Apr 14, 2013 5:42 pm

Re: A weird error I cant fix

Post 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)
cybercircuit
Prole
Posts: 16
Joined: Mon May 20, 2013 7:39 pm

Re: A weird error I cant fix

Post by cybercircuit »

THANK YOU!!!!
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: A weird error I cant fix

Post by Plu »

Can't believe I missed that :P
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: A weird error I cant fix

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 3 guests