Page 1 of 1

Game freezes and crashes after menu if I call a function

Posted: Sat Mar 14, 2015 12:25 am
by PeanutCarl
Hello, I'm fairly new to programming (I'd say I have like 2 weeks actually using lua and like 2 months of starting to read PIL) and so I started to make some sort of game (which doesn't really involve updating too many frames which is why I'm looking for a way to cap the fps to 30ish).

Anyway, I got the Menu screen down and the variables it should return to actually start the game, but I added a function (found in healthreward.lua) that I wanted to test, but whenever when I call it (Pressing "H" while on the play screen) LOVE will just freeze and crash. That's the only way to replicate the crash and I don't seem to figure out why it does that.

The code doesn't really use complex stuff because I'm not really too good neither experienced.

Sorry if I missed any points, but any help is greatly appreciated.

Here's the link to the .love file:

https://www.dropbox.com/sh/7wx1z6rxuxvu ... kINza?dl=0

Re: Game freezes and crashes after menu if I call a function

Posted: Sat Mar 14, 2015 1:15 am
by s-ol
PeanutCarl wrote:Hello, I'm fairly new to programming (I'd say I have like 2 weeks actually using lua and like 2 months of starting to read PIL) and so I started to make some sort of game (which doesn't really involve updating too many frames which is why I'm looking for a way to cap the fps to 30ish).

Anyway, I got the Menu screen down and the variables it should return to actually start the game, but I added a function (found in healthreward.lua) that I wanted to test, but whenever when I call it (Pressing "H" while on the play screen) LOVE will just freeze and crash. That's the only way to replicate the crash and I don't seem to figure out why it does that.

The code doesn't really use complex stuff because I'm not really too good neither experienced.

Sorry if I missed any points, but any help is greatly appreciated.

Here's the link to the .love file:

https://www.dropbox.com/sh/7wx1z6rxuxvu ... kINza?dl=0
Because there is the "while" loop that only stops when "setstate" is set to something other than "hpreward".
That is only changed when "c" is pressed, but that won't work because the keys will never get updated when your love.update keeps spinning.

That's why in löve (and wherever else there are per-frame-update-functions) you do not have "blocking" loops in those parts of code: Never wait for user input!

Also, please attach the .love in the post and not on dropbox. There's a feature for that.

Re: Game freezes and crashes after menu if I call a function

Posted: Sat Mar 14, 2015 2:00 am
by PeanutCarl
Thanks, that sounds pretty logical. And I tried to upload the .love as an attachment but the browser would just return a timeout error everytime I try, perhaps I have to update it, will do next time.