Page 1 of 2
ERROR
Posted: Sat Mar 12, 2011 11:11 pm
by madbaho
Ok, I wrote this game... I go run it in LOVE and it says......................
"main:lua:25: incorrect number of parameters
Traceback
[c]:in function 'newWorld'
main.lua:25: in function 'load'
[c]:in function 'xpcall' "
I'm confused on this error, it is forever hard to find support on this language compared to C++ and Java. I am running windows 7 64bit if that has anything to do with it i do not know... Please if anyone can please assist me in this manner please give me any tips or what is exactly causing this issue. This is my first LUA program ever and all i can say is I like PHP a lot better and i miss my java compilers
<----me being sad
I added the whole game and all files in a zip file, When i unzip and drag and drop main.lua onto love icon is when error is thrown.
Thank You so much,
Anthony
Re: ERROR
Posted: Sat Mar 12, 2011 11:14 pm
by bartbes
As the error tells you, it's at line 25 of main.lua, which is indeed a call to love.physics.newWorld. The docs tell you that newWorld requires 4 parameters now, which makes your 2 parameter call wrong, as the error states.
Re: ERROR
Posted: Sun Mar 13, 2011 12:00 am
by madbaho
I'm slightly confused why the line was asking for a integer on the res for physics? Also line 278 I'm printing text its asking for a string, and says the print is nil? You all know of any good referrences that I could read up on, or get proper syntax for these functions so I don't keep butchering this? Everything has been on a fly with this
Re: ERROR
Posted: Sun Mar 13, 2011 12:34 am
by BlackBulletIV
Programming in Lua is a good book on Lua.
And don't despair so easily, it's not like you're going to get everything right with a first program.
Re: ERROR
Posted: Sun Mar 13, 2011 12:40 am
by Robin
As the documentation on
love.physics.newWorld will tell you, you need to give it four parameters. This was different in the past.
madbaho wrote:Also line 278 I'm printing text its asking for a string, and says the print is nil?
The variable "text" is nil, because it is not set until some specific collision occurs.
madbaho wrote:You all know of any good referrences that I could read up on, or get proper syntax for these functions so I don't keep butchering this? Everything has been on a fly with this
The
PIL, for example.
Re: ERROR
Posted: Sun Mar 13, 2011 12:59 am
by slime
The online version of PIL is many years out of date and references some obsolete/deprecated things. There's also the
Lua-users Tutorial, the PIL book, and many other resources found through the googles.
The
LÖVE Wiki does a decent job of documenting things specific to LÖVE, and looking at other people's code can also help a lot.
Re: ERROR
Posted: Sun Mar 13, 2011 2:16 am
by madbaho
I tried another tutorial, I went line by line and I still have an issue with another print statement... I check and view and I cannot find a solution. The only issue was with the collision, before i added the collision it worked great.
Tutorial
http://www.brighthub.com/hubfolio/matth ... -love.aspx
Each link is another step you see on that page... I was on Collision Detection, ran into an issue so i finished the weapons step and trying to fix collision now.
syntax error:collisionmanager.lua:26:'=' expected near 'order'
I double checked and double checked with tutorial and I cannt find my problem? Anyone help? My code matches exactly
Re: ERROR
Posted: Sun Mar 13, 2011 3:44 am
by leiradel
madbaho wrote:syntax error:collisionmanager.lua:26:'=' expected near 'order'
This line is:
Lua first sees a call statement, and then it tries to parse "In order." Since In is an identifier, it assumes that the statement is an assignment and spits the error message.
You must have made a mistake copying and pasting from the tutorial. Remove "In order" from that line and try running the game again.
Cheers,
Andre
Re: ERROR
Posted: Sun Mar 13, 2011 4:01 am
by tentus
Some general advice:
- Indent. I've attached a .love which has marginally improved indentation. It'll help you keep track of where you are and what you're doing in your code.
- Use
PO2 images so that computers that can't render them will still be able to play.
- Don't require anything more than once. One, its not doing anything code-wise, and two, it encourages bad coding habits. Only require class once.
- Comment everything that isn't self evident. I will often put the
why in my comments, like this:
Code: Select all
player.y = player.y - 32 -- Move up by 32 so that the next update doesn't also collide
I've attached a .love (the preferred format for distributing code around here) with some adjustments based on the advice above. Good luck!
Re: ERROR
Posted: Sun Mar 13, 2011 8:59 am
by crow
tentus wrote:Some general advice:
- Indent. I've attached a .love which has marginally improved indentation. It'll help you keep track of where you are and what you're doing in your code.
- Use
PO2 images so that computers that can't render them will still be able to play.
- Don't require anything more than once. One, its not doing anything code-wise, and two, it encourages bad coding habits. Only require class once.
- Comment everything that isn't self evident. I will often put the
why in my comments, like this:
Code: Select all
player.y = player.y - 32 -- Move up by 32 so that the next update doesn't also collide
I've attached a .love (the preferred format for distributing code around here) with some adjustments based on the advice above. Good luck!
your demo give me a error when i hit space bar was that meant to be a error demo ?