Game with separate files tryout

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.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Game with separate files tryout

Post by zorg »

Well, it's your decision reading the tutorials or not; not really our jobs to hand-hold. :o:
Edit: wow, i was ninja'd by a whole page... fml.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Game with separate files tryout

Post by MadByte »

SynfigMaster91 wrote: Fri Dec 15, 2017 7:39 pm here's the file. It's out there.
Thanks.

Code: Select all

10     if love.keyboard.isDown("right") then
11       10 + 40 * dt
12     end
So you changed all variables to static numbers and also didn't tell lua how it should use the results of your calculations.
How should LÖVE/Lua know what these calculations are for? As result, lua throws an error telling you that there has to be something wrong with your code on line 11 and stops searching for more errors.

Your previous code was fine, and I uploaded a working example showing how the code could look like. So why don't you start with the working example and experiment with it until you understand how the syntax has to look like.

Another problem I've seen is that you tried using colon syntax and self and mixed this with the dot syntax...

Code: Select all

function square:setup()
  self.img  = love.graphics.newImage('player.png')
  self.x    = 100
  self.y    = 100
end
Generally this will be the way to go later, but for now you should avoid using self and the colon syntax and stick with the dot.
As a starting point I would suggest reading a bit more about variables, operators and tables and how they work. The lua pil is a good source where you'll find answers for almost everything lua related.

Edit - Zorg is right, we won't hand-hold you through every error you get, so please take our advises and try learning the lua language to some extend. It might be hard when you are new and we are willing to help, but most of the errors you got can be solved with just reading and researching what the error handler displays.
SynfigMaster91
Prole
Posts: 17
Joined: Thu Nov 23, 2017 4:46 pm

Re: Game with separate files tryout

Post by SynfigMaster91 »

MadByte wrote: Fri Dec 15, 2017 8:21 pm
SynfigMaster91 wrote: Fri Dec 15, 2017 7:39 pm here's the file. It's out there.
Thanks.

Code: Select all

10     if love.keyboard.isDown("right") then
11       10 + 40 * dt
12     end
So you changed all variables to static numbers and also didn't tell lua how it should use the results of your calculations.
How should LÖVE/Lua know what these calculations are for? As result, lua throws an error telling you that there has to be something wrong with your code on line 11 and stops searching for more errors.

Your previous code was fine, and I uploaded a working example showing how the code could look like. So why don't you start with the working example and experiment with it until you understand how the syntax has to look like.

Another problem I've seen is that you tried using colon syntax and self and mixed this with the dot syntax...

Code: Select all

function square:setup()
  self.img  = love.graphics.newImage('player.png')
  self.x    = 100
  self.y    = 100
end
Generally this will be the way to go later, but for now you should avoid using self and the colon syntax and stick with the dot.
As a starting point I would suggest reading a bit more about variables, operators and tables and how they work. The lua pil is a good source where you'll find answers for almost everything lua related.

Edit - Zorg is right, we won't hand-hold you through every error you get, so please take our advises and try learning the lua language to some extend. It might be hard when you are new and we are willing to help, but most of the errors you got can be solved with just reading and researching what the error handler displays.
I tested it by myself and now it works! Thank you so much! :ultraglee:

Also, I'm so sorry about my temper and my impatience about before. I remember I should've add another function to put the variables there. Mistake of mine. I don't know why my head forgets important stuff. :ehem:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests