Page 4 of 4

Re: Game with separate files tryout

Posted: Fri Dec 15, 2017 8:15 pm
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.

Re: Game with separate files tryout

Posted: Fri Dec 15, 2017 8:21 pm
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.

Re: Game with separate files tryout

Posted: Sat Dec 16, 2017 2:41 pm
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: