Error when running my game
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Error when running my game
Whenever i run my game it says that its comparing a value with nil which doesnt make any sense. i even changed the value to 1 to see if that worked and it didnt! i have provided the .love for you all to see the source code
- Attachments
-
- CodeClicker.love (2).love
- (1.1 KiB) Downloaded 126 times
Re: Error when running my game
So whenever I run my love game it says that it was comparing a value with nil (its on cookie.lua line 26) im not really understanding why..?
i even tried changing the value to 1 or something higher and its still giving the same error so im not really sure what to do. anyone who sees this please help!
i even tried changing the value to 1 or something higher and its still giving the same error so im not really sure what to do. anyone who sees this please help!
Re: Error when running my game
So whenever I run my love game it says that it was comparing a value with nil (its on cookie.lua line 26) im not really understanding why..?
i even tried changing the value to 1 or something higher and its still giving the same error so im not really sure what to do. anyone who sees this please help!
i even tried changing the value to 1 or something higher and its still giving the same error so im not really sure what to do. anyone who sees this please help!
Re: Error when running my game
oh im sorry i thought i posted wrong... please dont take down my post for spam as i sincerely got confused
Re: Error when running my game
I think your .love is incorrectly packed:
[love "boot.lua"]:321: No code to run
Your game might be packaged incorrectly.
Make sure main.lua is at the top level of the zip.
[love "boot.lua"]:321: No code to run
Your game might be packaged incorrectly.
Make sure main.lua is at the top level of the zip.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Error when running my game
how do you pack it correctly then?
Re: Error when running my game
zip:
- main.lua
- all your other files
- all your folders with subfolders
Re: Error when running my game
Basically what darkfrei is saying is that you should not zip the folder, because then main.lua is not in the top level, but in a folder, and then it doesn't work.
Anyway, the error you're getting makes perfect sense, because the following code is executed BEFORE cookie:load():
Basically, when you load a file, Lua runs everything in that file. If there are function definitions, the effect of running them is to define the functions. And when it has all the functions defined, then it runs "if cookie.clicks >= 5 then", and it notices that cookie.clicks does not have any value (because cookie:load() is defined, but it hasn't run yet!) and that means that cookie.clicks is nil, which you try to compare with 5, and crashes.
Maybe you meant that to be inside cookie:mousepressed(), or somewhere else, so that it is executed after cookie:load().
Then you have another problem in distance.lua; the argument order is wrong. You have distanceBetween(x1, x2, y1, y2) but it should be distanceBetween(x1, y1, x2, y2). Or you could call it with the arguments in the specified order, first all X and then all Y, but that's not very conventional.
Anyway, the error you're getting makes perfect sense, because the following code is executed BEFORE cookie:load():
Code: Select all
if cookie.clicks >= 5 then
print("boi!")
end
Maybe you meant that to be inside cookie:mousepressed(), or somewhere else, so that it is executed after cookie:load().
Then you have another problem in distance.lua; the argument order is wrong. You have distanceBetween(x1, x2, y1, y2) but it should be distanceBetween(x1, y1, x2, y2). Or you could call it with the arguments in the specified order, first all X and then all Y, but that's not very conventional.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 13 guests