Error: Bad Argument #2 to rectangle

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
User avatar
MattyAB
Citizen
Posts: 57
Joined: Wed Mar 25, 2015 8:37 pm

Error: Bad Argument #2 to rectangle

Post by MattyAB »

Hey Everyone,

So I've just started making my first proper game (Check it out here: https://github.com/tom7tomm/SuperDodger), and have got an error whilst trying to create a rectangle to be drawn on the scree. It says "Error: Bad Argument #2 to rectangle (number expected, got nil)" This only happens when I press space to start the game, and I will upload a .love file. How do I stop this?

Thanks!
Attachments
game.love
(65.2 KiB) Downloaded 88 times
Check out my blog - The place to find out about the latest tech news! http://thegeekcircle.blogspot.co.uk/
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Error: Bad Argument #2 to rectangle

Post by micha »

The error means that the second argument in the rectangle call is nil, but a number is needed. The second argument is player.x. It is defined in player.load, player.load is never run. To fix this, add player.load to line ~24 in menu.lua (where you switch from menu to gameplay).
User avatar
MattyAB
Citizen
Posts: 57
Joined: Wed Mar 25, 2015 8:37 pm

Re: Error: Bad Argument #2 to rectangle

Post by MattyAB »

Aha, thanks. Didn't notice that I never said to run player.load!
Check out my blog - The place to find out about the latest tech news! http://thegeekcircle.blogspot.co.uk/
Post Reply

Who is online

Users browsing this forum: Google [Bot], PotatoDude and 202 guests