ERROR

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.
madbaho
Prole
Posts: 4
Joined: Sat Mar 12, 2011 11:03 pm

ERROR

Post 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
Attachments
artillary.zip
GAME Artillary
(1.14 MiB) Downloaded 178 times
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: ERROR

Post 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.
madbaho
Prole
Posts: 4
Joined: Sat Mar 12, 2011 11:03 pm

Re: ERROR

Post 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
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: ERROR

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: ERROR

Post 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.
Help us help you: attach a .love.
User avatar
slime
Solid Snayke
Posts: 3161
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: ERROR

Post 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.
madbaho
Prole
Posts: 4
Joined: Sat Mar 12, 2011 11:03 pm

Re: ERROR

Post 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
Attachments
demogame.zip
My space game tutorial
(575.96 KiB) Downloaded 129 times
User avatar
leiradel
Party member
Posts: 184
Joined: Thu Mar 11, 2010 3:40 am
Location: Lisbon, Portugal

Re: ERROR

Post by leiradel »

madbaho wrote:syntax error:collisionmanager.lua:26:'=' expected near 'order'
This line is:

Code: Select all

print("collide")In order
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
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: ERROR

Post 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!
Attachments
space.love
v2
(574.71 KiB) Downloaded 149 times
Last edited by tentus on Sun Mar 13, 2011 9:33 am, edited 1 time in total.
Kurosuke needs beta testers
User avatar
crow
Party member
Posts: 186
Joined: Thu Feb 24, 2011 11:47 pm
Location: UK
Contact:

Re: ERROR

Post 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 ?
Sir Kittenface
Möko IDE Codename (Erös) Returns Soon

I am dyslexic so if any of my replys confusing please just ask me to reword it as this will make things a lot easier for all parties lol.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests