I came looking for copper and found gold. This is absurdly amazing compared to many other tutorials. Can't find another tutorial to be such beginner friendly.
4:15 This is the first video that I've ever seen that explains what an 'argument' is. So many other programming & game making tutorials use the term without explaining what it is. I was planning to look it up and try to find out what it means, but I hadn't gotten around to it because there is so much to learn, it wasn't the highest priority. Thanks for going into detail.
Thanks for that superb tutorial series! You're really good at conveying information and engaging the viewer. And as pointed out it's a nice show of code structuring
I was scripting before in Multi Theft Auto and I have a lot knowedge, don't need watch tutorials but this one is great! I love this! Waiting for more stuff
In future videos please zoom a littlebit in. My screen is not that big and full screen is not nice, because I switch between VScode an youtube. But all in all thank you for this video series. I learn a lot. :)
I promised my eight-year-old nephew that if he left a little fornite, I would teach him how to make his own games (on roblox, c #, c ++, at 8 I don't want to put him off), but like everything in its time, i gave him my lua guide from my youth today, he hasn't let go all day and he has already written his first lines of code on his phone. I just read the roblox api and I thought that diving it first in love2D would be a good deal because it is much more affordable for its young age. So thank you for helping me get back into it. By the way, if you have a problem with dt, put this at the start of the Player: update () block => dt = love.timer.getDelta (), hope that helps.
It's a really great idea to teach kids programming, it will help them a lot in life! I would recommend against setting dt manually, then you will need to do it everywhere. The most likely reason it did not work for you is that you have forgotten to pass dt at some point. In love.update(dt), you need to call player:update(dt). Inside of your player file you need to declare player:update(dt) with a dt inside of it. If this does not solve the issue, you can send me the code (use pastebin or google drive) and I will have a look.
No idea what Löve is? Check out my introduction video to Löve: ruclips.net/video/ZQCky-_Ad5Y/видео.html Little to no Lua/programming experience, check out my crash course in Lua: ruclips.net/video/xRKIIV4-cfk/видео.html Make sure to join our DISCORD server: discord.gg/mUaVASvG4z :) Full source code: github.com/Jeepzor/Pong-tutorial
Just got interested in programing in Lua and Löve, and your videos are helping a lot! Even if I'm doing everything using my phone I think I'll be able to make something.
Wow, I didn't watch the whole video but from what I had seen already it seems that it is much easier to make game with Lua in comparison to JavaScript. For example, to make a pong game you could use something called HTML CANVAS. Where you would have to perform lots of code rush to create a simple pong game, excellent video.
@@dreamy97836 Yea I am still learning, I never used a library or framework yet only Vanilla JavaScript. I have lots to learn. But I like the syntax of Lua and I read good things about this language. One day I will try this out.
Hi Jeeper, i'm watched two videos before this about learning love/lua, you make a brilliant work explaining things about game dev with love and lua. I'm a guy wich love video game and think learning game dev for years. A long time search material like this, i loved your videos, hoewever this video sequence in three parts, do not have correctly english to portuguese brazilian translator , only Vietnam language to portuguese brazilian and its wrong. Please help me to understandand the class, the concepts and continue learning game dev, thank you for all!
@@DevJeeper thank you!! Your tutorials are really helpful and intuative. If it weren't for you, I wouldn't know how to call in a different file into the game. Thank you! If my game does realease soon I will tell you where you can find it! Your the absoulute best!! You also taught me how to make simple equations in the game so then the player starts in a certain spot. I can't put in words how much you have helped me. You literally taught me everything I need to know on how to make a game, and at the end of the tutorial you even showed how to decorate the game too! Without that I wouldn't have been able to call in an image, let alone have it has the player! Also the simple making of the AI helped me understand in depth on how this programming language works. You really are the best and deserve a lot more than what you have. (btw i also code on windows with atom text editor, Atom is really great!)
@@DevJeeper Hey it's me again. Some things happened to say...... basically I didn't really start this project until now. Not sure why, but I did check out some other things like Pygame before settling on LOVE2D. For some reason it won't let me multiply the speed by delta time, giving the error of player.lua:18: appempt to perform artihmetic on local 'dt' (a nil value)." I tried to search it up online on forums and whatnot, but nothing seemed to fix it. This happens every time that I try to move the paddle, and if I remove multiplying self.speed by dt then everything works fine. Not sure what the problem is.
So my editor doesn't predict or show me options for the blue text. Do I need to find a different editor? or is there someplace I can memorize all of these? I am referencing the blue text like, isDown, getHeight ect.
This might be very late but I want to use for example player.x and player.y instead of self.x and self.y. When I replace it it gives an error do you know why?
I have a problem. LOVE tells me "attempt to index local 'self' (a nil value)" in Player.lua. It only happens after I moved code from Player:update to Player:move(dt) and Player:checkBoundaries().
Full error: Error player.lua:29: attempt to index local 'self' (a nil value) Traceback player.lua:29: in function 'checkBoundaries' player.lua:13: in function 'update' main.lua:8: in function 'update' [C]: in function 'xpcall'
Sorry, I am an idiot and assumed you can call functions using '.', but you used ':' instead and I didn't notice it. It turns out you need to use ':' to supply self.
You could think of velocity as an objects current movement speed. X & Y let us know which axis that movement takes place on. Negative Y velocity = Going up Positive Y velocity = Going down Negative X velocity = Going to the left Positive X velocity = Going to the right If the Y-velocity is 100, then it is traveling down 100 pixels per second (since we multiply it with dt)
@@darthom Correct, the direction comes from whether or not the value is negative/positive, and the number is simply how fast it is going. So 10 is slower than 100, and -10 is slower than -100.
The error only tells me part of the problem, kind of like an editor reviewing your book and saying "There are some problems on page 437, paragraph 3". Without the book, or in this case the code I can only guess. So if none of my guesses solve the problem, please send me the code (preferably with a google drive link). Possible reasons: You forgot to require the player file in main.lua. You named the table "player" but call it "Player", it's case sensitive.
@@DevJeeper I got the same error, here is the code I wrote: Player = {} function Player:load() self.x = 50 self.y = love.graphics.getHeight() / 2 self.width = 20 self.height = 300 self.speed = 500 end function Player:update(dt) end function Player:draw() love.graphics.rectange("fill",self.x,self.y,self.width,self.height) end And this is the error: Error player.lua:4: attempt to index local 'self' (a nil value) Traceback player.lua:4: in function 'load' main.lua:7: in function 'load' [C]: in function 'xpcall' [C]: in function 'xpcall'
When I first installed Atom It didn't have an option for Lua coding but I managed using community packages but I'm starting to think it's breaking some things and it's also making me uncomfortable with the "style" I guess, can you tell me how you got Lua on your Atom?
For the syntax highlighting I use this package: gyazo.com/a75484c643f67f9e9becf6505537a79c On top of that I have made my own stylesheet which sets the colors (to the ones you see in the video). Is this something you would like me to cover in a video?
Hmmm am I missing something? Followed up to the point of drawing the rectangle but nothing showed up, just a blank black screen and no error even with console = true, no console window popped up on Mac. And yes, main.lua file has the Player functions inserted as taught. Also tested with a previous Love2d version on replit with the same blank screen result. Any advise? :) Thanks for the tutorials!
Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord or alternatively email :)
Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord 🙂
Thanks for letting me know, and good job on solving it yourself. Awesome to hear that you used the videos to create something entirely different on your own! I would love to try it out if you want to share it :)
Technically there is no object oriented programming in Lua since there are no "real objects". However, lua gives you all of the tools to emulate it. Colon simply passes the table as an argument which is named self. You could get the exact same result by doing: function Player.printHealth(self) print(self.hp) end and then calling it: Player.printHealth(Player) or Player:printHealth()
Hello, first of all, thank you so much for this tutorial! Glad to found a 'lua' tutorials for beginner like me. Thanks :) . By the way, I have some questions regarding the functions inside the Player:update function this code: --- function Player:move(dt) if love.keyboard.isDown("w") then self.y = self.y - self.speed * dt elseif love.keyboard.isDown("s") then self.y = self.y + self.speed * dt end end --- 1. First question is, can you (or maybe someone) explain the logic? I could not understand this function. I know that the self.y is the coordinate of the player in regards to y axis (CMIIW) and self.speed is how fast the player move on pixel/second (CMIIW). but how does this two (self.y and self.speed) make the player move up and down when there is no definition of direction within the function (like self.y + 300 or self.y -300)? I hope my question makes sense :) i just can't understand how that 20x100 white box could move up and down, when only it self.y (coordinate) and self.speed (speed) use in the function without actually determine the direction of the movement in the y axis (like -y or +y)? would be really helpfull if someone could elaborate, i want to include this in the comment of the code. thanks again.
@@DevJeeper Oh, so in other words, self.speed is the one that determine the direction of the movement of the box in y axis in the code: self.y = self.y - self.speed * dt ? Thanks for the answer!
@@DevJeeper thanks for the explanation :) . also thanks for all the efforts in making lua-love2D tutorials :) it helped me a lot in learning lua and also in programming :))
I've copied your code exactly and I'm getting the error "player.lua:21: attempt to perform arithmetic on local 'dt' (a nil value)". The only way to fix this is to take out dt in the line "self.y = self.y - self.speed * dt" but obviously that isn't ideal. Is there any way I can fix this?
For me to be able to say what the reason is with certainty I need to see your code. The error code allows to make a couple of guesses though. First of all, the problem is that “dt” is equal to nil, meaning it’s not available in the scope of the function. My best guess is that you either forgot to include “dt” as an argument when calling the function, or in the function itself. Alternatively you use a colon in the function but a dot when you call it. If neither of these are the cause then I need to see the code to help you.
It would go faster if you included the full code, there are multiple different things that could be wrong. Now right now the most likely reason is that you called "Player:update()" in the main.lua file, omitting to pass "dt".
@@snakelele4148 You are most welcome! Getting an error with "dt" being nil is actually a fairly common thing, because it's very easy to miss passing it somewhere in the chain. To fix it one should do what we just did, start from where the crash occurs and work your way backwards to love.update; double checking that dt is passed along each step of the way.
Lua is a programming language, Löve is a framework. Frameworks are more lightweight than an engine such as unity. I prefer Löve since it allows me to write the entire structure myself, I love the fact that you make a new project by literally just creating a new folder. There are also libraries that you can use for common things such as animations and gui.
for some reason, the script doesn't work.. i typed it out and everything, i understand it too.. i also tried copy and pasting from the link in the description with no success. i've saved the script as well. could you please help? loving the series btw! you've earned a sub
I would love to help! However I need you to link me your code (preferably on pastebin or google drive) and tell me a little bit more about what it is that doesn’t work.
@@DevJeeper actually, i believe i found the problem for the rectangle drawing out part. i did "function Player:draw()" instead of "function love.draw()". would this work the same?
Your main file seems to be empty, apart from the require of the player file. You need to indeed declare love.load, update & draw there. Then you should call the players functions there. This is something which I cover in the video so if you feel uncertain I suggest rewatching it :) Let me know if you need more help or pointers and I will do my best to help you :D
Hey there! Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord or alternatively email :)
@@DevJeeper sorry i was dumb enough to forgot to put the Player:draw(), Player:update(dt) and Player.load() in the main .lua functions. But when i did this its give me this error code: Error main.lua:4: attempt to index global 'Player' (a nil value) Traceback [love "callbacks.lua"]:228: in function 'handler' main.lua:4: in function 'load' [love "callbacks.lua"]:136: in function [C]: in function 'xpcall' [C]: in function 'xpcall'
You are not dumb! Making mistakes is part of programming, everyone makes them. Finding them and fixing is just part of the game :) Well done for figuring it out your self!
Yeah for people with any kind of game development experience this will feel quite natural (as it's very common). However, people who don't have that will usually think of the Y-axis flipped to this, since this is more common in other areas.
I already have a love-hate relationship with lua. It's giving me an error saying: Error player.lua:5: attempt to call field 'getheight' (a nil value) Traceback player.lua:5: in function 'load' main.lua:4: in function 'load' [C]: in function 'xpcall' [C]: in function 'xpcall' And I don't fully understand it at all. Even if I copy the parts from your github project into a new project it doesn't work, so I can't even get past the part where the engine draws a rectangle
Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord 🙂
While it isn't really needed in this tutorial, it's really good to get used to using "self" since it kind of is a cornerstone when you start coding object oriented.
@@DevJeeper I do have it so tables have their own functions that get called later like: t={} t.draw=drawtri -- later ... for i=1,#tri do t=tri[i] t:draw() end So I kinda do something like that?
Yeah you could say it's kinda like that :) The the next tutorial series (after Pong) will be focused on more object oriented programming. I will try my best to explain in in detail then!
This is a great tutorial for both Lua and love2d, but after you start dividing thing in different functions, my syntax isn't right anymore. And could you please use comments? It makes things easier when i see this project again after 2 months. Error Syntax error: main.lua:22: function arguments expected near 'end' Traceback [C]: at 0x010a70db20 [C]: in function 'require' [C]: in function 'xpcall' [C]: in function 'xpcall' some more information: function Player:update(dt)
Hey there, thank you for the kind words! I have added a link in the description to this episodes code, and I have gone ahead and commented it. The reason I don't comment code during the tutorial is best for your learning to make your own comments. I will explain the code, and then you can put it down with your own words. Now when it comes to your error, it's very difficult for me to know what your problem is, because error messages only tell me where in your code there is an issue, not necessarily what it is. If you could send me your code, I will have a look at it and help you figure out the problem! Thank you for the feedback, I have had some people say its too fast (and some that thought it was too slow), but I will keep it in mind for the next tutorial series! :)
@@DevJeeper Thank you, you're one of the first person with coding tutorials that actually responds to questions. I put some additional code in there about moving, and it worked before the function switching. I don't know what went wrong, but i started over from your code and now it works again.
@@marn200 Awesome that you managed to sort it out yourself! It's very often small mistakes that are easy to make, but difficult to find. I do plan to continue responding to all comments, so I'm glad to hear it's appreciated! :)
@@skytheambatablow Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord 🙂
From the VERY START of this video I can tell the title of this video is false and a game is not created in "3 easy steps". It's more like 12 to 20 easy steps including; listening to different sets of instructions. If such a game were made in 3 easy steps, easily and only in the 3 steps only, you would not still be reading this comment here, you would have already created a new game to completion.
I’m assuming your joking, but on the off-chance that you are serious: The series is split into 3 parts: Making the player, making the ball and making the opponent paddle. I have done my best to simplify the logic as much as possible and keep the videos short. I’m sorry if you found it too difficult, this was the first series I made :) Feel free to come with some feedback on parts you feel where not explained enough!
Thank you for a very awesome tutorial! Its just that when I run it it says this Error player.lua:1: attempt to call global 'player' (a nil value) Traceback [love "callbacks.lua"]:228: in function 'handler' player.lua:1: in main chunk [C]: in function 'require' main.lua:1: in main chunk [C]: in function 'require' [C]: in function 'xpcall' [C]: in function 'xpcall' Can you please reply and help me on this? Thank you
Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord or alternatively email :)
When I try this it just tells me "Error Syntax error: main.lua:3: '=' expected near 'love' Traceback [C]: at 0x613dd550 [C]: in function 'require' [C]: in function 'xpcall' [C]: in function 'xpcall'"
I need to see what ”this” is :D Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord or alternatively email :)
I don't understand why this is happening. Any help would be appreciated. Error player.lua:29: attempt to index local 'self' (a nil value) Traceback [love "callbacks.lua"]:228: in function 'handler' player.lua:29: in function 'checkBoundaries' player.lua:16: in function 'update' main.lua:9: in function 'update' [love "callbacks.lua"]:162: in function [C]: in function 'xpcall'
I can make a guess, you forgot to use a : when declaring or calling the 'checkBoundaries' function. For example typing Player.checkBoundaries instead of Player:checkBoundaries. If that is not the case, then I will need to see your code to help you figure it out.
No, you shouldn't do that (at least not for the purpose that you are doing it). If you are "having problems getting delta time", then it is because you are forgetting to pass it along, or forgetting to declare the argument. Instead of making a "dirty hack" to get it to work, you should remove it and search for the error you made. If you want help finding it you can join the discord server and post your code there!
I came looking for copper and found gold. This is absurdly amazing compared to many other tutorials. Can't find another tutorial to be such beginner friendly.
Haha, thank you! I'm glad to hear that you found the videos helpful :D
Hi, I know the video is kinda old now. But I wanted to thank you, I'm completely new to programming and this is the only tutorial that worked for me
4:15 This is the first video that I've ever seen that explains what an 'argument' is. So many other programming & game making tutorials use the term without explaining what it is. I was planning to look it up and try to find out what it means, but I hadn't gotten around to it because there is so much to learn, it wasn't the highest priority. Thanks for going into detail.
That's nice to hear, best of luck! :)
Thanks for that superb tutorial series! You're really good at conveying information and engaging the viewer. And as pointed out it's a nice show of code structuring
Glad to hear it was helpful! :D
I was scripting before in Multi Theft Auto and I have a lot knowedge, don't need watch tutorials but this one is great! I love this! Waiting for more stuff
That's really cool to hear, thank you! Later down the line I will be covering more advanced topics as well!
I'm already a programmer. But, I'm using this video to adopt a few more techniques and ideas and this video makes it easy.
Happy to hear that you found it useful, even with your previous experience :)
In future videos please zoom a littlebit in. My screen is not that big and full screen is not nice, because I switch between VScode an youtube.
But all in all thank you for this video series. I learn a lot. :)
Thank you for the feedback, this is something that has changed in the later videos :)
I promised my eight-year-old nephew that if he left a little fornite, I would teach him how to make his own games (on roblox, c #, c ++, at 8 I don't want to put him off), but like everything in its time, i gave him my lua guide from my youth today, he hasn't let go all day and he has already written his first lines of code on his phone. I just read the roblox api and I thought that diving it first in love2D would be a good deal because it is much more affordable for its young age. So thank you for helping me get back into it. By the way, if you have a problem with dt, put this at the start of the Player: update () block => dt = love.timer.getDelta (), hope that helps.
It's a really great idea to teach kids programming, it will help them a lot in life!
I would recommend against setting dt manually, then you will need to do it everywhere. The most likely reason it did not work for you is that you have forgotten to pass dt at some point. In love.update(dt), you need to call player:update(dt). Inside of your player file you need to declare player:update(dt) with a dt inside of it. If this does not solve the issue, you can send me the code (use pastebin or google drive) and I will have a look.
@@DevJeeper Thanks friend. I'm well placed to know that kids only have the limits that we the parents are giving to them.
No idea what Löve is? Check out my introduction video to Löve: ruclips.net/video/ZQCky-_Ad5Y/видео.html
Little to no Lua/programming experience, check out my crash course in Lua: ruclips.net/video/xRKIIV4-cfk/видео.html
Make sure to join our DISCORD server: discord.gg/mUaVASvG4z :)
Full source code: github.com/Jeepzor/Pong-tutorial
This is the 3rd time I'm making pong to learn a language, I'm 12 lol
My 2nd......
My 1st lol
Bro, this is my tenth time, and I'm 12 too
Is this the secret pong-making club? :D
@@DevJeeper only the least skilled of programmers can join this, sadly I had to leave as I made a score based game I'm 14 now
Just got interested in programing in Lua and Löve, and your videos are helping a lot!
Even if I'm doing everything using my phone I think I'll be able to make something.
Mad respect programming on your phone! Best of luck :)
the feeling of just being able to move is great
It sure is! (☞゚ヮ゚)☞
Wow, I didn't watch the whole video but from what I had seen already it seems that it is much easier to make game with Lua in comparison to JavaScript. For example, to make a pong game you could use something called HTML CANVAS. Where you would have to perform lots of code rush to create a simple pong game, excellent video.
@@dreamy97836 Yea I am still learning, I never used a library or framework yet only Vanilla JavaScript. I have lots to learn. But I like the syntax of Lua and I read good things about this language. One day I will try this out.
Great videos
Great video !
Hi Jeeper, i'm watched two videos before this about learning love/lua, you make a brilliant work explaining things about game dev with love and lua. I'm a guy wich love video game and think learning game dev for years. A long time search material like this, i loved your videos, hoewever this video sequence in three parts, do not have correctly english to portuguese brazilian translator , only Vietnam language to portuguese brazilian and its wrong. Please help me to understandand the class, the concepts and continue learning game dev, thank you for all!
this is gonna be my first game, and also i am 12 and becoming a game dev lol
That’s super cool! You are starting out earlier than I did :)
If you run into any issues let me know and I will do my best to help you. Good luck!
@@DevJeeper thank you!! Your tutorials are really helpful and intuative. If it weren't for you, I wouldn't know how to call in a different file into the game. Thank you! If my game does realease soon I will tell you where you can find it! Your the absoulute best!! You also taught me how to make simple equations in the game so then the player starts in a certain spot. I can't put in words how much you have helped me. You literally taught me everything I need to know on how to make a game, and at the end of the tutorial you even showed how to decorate the game too! Without that I wouldn't have been able to call in an image, let alone have it has the player! Also the simple making of the AI helped me understand in depth on how this programming language works. You really are the best and deserve a lot more than what you have. (btw i also code on windows with atom text editor, Atom is really great!)
I'm 14
@@DevJeeper Hey it's me again. Some things happened to say...... basically I didn't really start this project until now. Not sure why, but I did check out some other things like Pygame before settling on LOVE2D. For some reason it won't let me multiply the speed by delta time, giving the error of player.lua:18: appempt to perform artihmetic on local 'dt' (a nil value)." I tried to search it up online on forums and whatnot, but nothing seemed to fix it. This happens every time that I try to move the paddle, and if I remove multiplying self.speed by dt then everything works fine. Not sure what the problem is.
@@tyland6732 Could you give me a link to your code? I would love to take a look and help you out! :)
So my editor doesn't predict or show me options for the blue text. Do I need to find a different editor? or is there someplace I can memorize all of these? I am referencing the blue text like, isDown, getHeight ect.
lua isn't so different from c#, but I cant help but add a semi colon.....
Good thing that semicolons don't break lua, it's simply ignored by the interpreter :)
This might be very late but I want to use for example player.x and player.y instead of self.x and self.y. When I replace it it gives an error do you know why?
For some reason when I run the program, it shows a black screen. Can you help me?
5:19 my place
I have a problem. LOVE tells me "attempt to index local 'self' (a nil value)" in Player.lua. It only happens after I moved code from Player:update to Player:move(dt) and Player:checkBoundaries().
Full error:
Error
player.lua:29: attempt to index local 'self' (a nil value)
Traceback
player.lua:29: in function 'checkBoundaries'
player.lua:13: in function 'update'
main.lua:8: in function 'update'
[C]: in function 'xpcall'
Sorry, I am an idiot and assumed you can call functions using '.', but you used ':' instead and I didn't notice it. It turns out you need to use ':' to supply self.
Nothing to say sorry about; you are not an idiot. These things happen to everyone! :)
I am glad someone else had this problem and got it fixed, I was wondering what happened.
Hi, I have problem understand xVel and yVel. I googled it and it's say it's the speed + direction.
You could think of velocity as an objects current movement speed. X & Y let us know which axis that movement takes place on.
Negative Y velocity = Going up
Positive Y velocity = Going down
Negative X velocity = Going to the left
Positive X velocity = Going to the right
If the Y-velocity is 100, then it is traveling down 100 pixels per second (since we multiply it with dt)
@@DevJeeper so if I understand correct it's like saying speed.x and speed.y. its the direction of movement of the ball.
@@darthom Correct, the direction comes from whether or not the value is negative/positive, and the number is simply how fast it is going. So 10 is slower than 100, and -10 is slower than -100.
error : main.lua:4: attempt to index global 'Player' (a nil value)
help.
The error only tells me part of the problem, kind of like an editor reviewing your book and saying "There are some problems on page 437, paragraph 3". Without the book, or in this case the code I can only guess. So if none of my guesses solve the problem, please send me the code (preferably with a google drive link). Possible reasons:
You forgot to require the player file in main.lua.
You named the table "player" but call it "Player", it's case sensitive.
@@DevJeeper I got the same error, here is the code I wrote:
Player = {}
function Player:load()
self.x = 50
self.y = love.graphics.getHeight() / 2
self.width = 20
self.height = 300
self.speed = 500
end
function Player:update(dt)
end
function Player:draw()
love.graphics.rectange("fill",self.x,self.y,self.width,self.height)
end
And this is the error:
Error
player.lua:4: attempt to index local 'self' (a nil value)
Traceback
player.lua:4: in function 'load'
main.lua:7: in function 'load'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
Edit: I think I found the error, inside main.lua I accidentally wrote Player.load() /.update() /etc instead of Player:load()
When I first installed Atom It didn't have an option for Lua coding but I managed using community packages but I'm starting to think it's breaking some things and it's also making me uncomfortable with the "style" I guess, can you tell me how you got Lua on your Atom?
For the syntax highlighting I use this package: gyazo.com/a75484c643f67f9e9becf6505537a79c
On top of that I have made my own stylesheet which sets the colors (to the ones you see in the video).
Is this something you would like me to cover in a video?
@@DevJeeper oooooh yes please! Thanks!
hey i deleted my last comment for some reason but now i fixed it but i have a new problem
what is that symbol at 5:01 next to self.speed?
As I say in the video, we multiply it, aka *
:)
@@DevJeeper sorry idk much about lua language
Do you have a discord server?
No I don't have one... yet :)
Great Tutorial but something isn't working for me. When I draw the rectangle, it doesn't show up.
Since you asked another question in the next video I assume you resolved this problem?
@@DevJeeper yeah. I know you needed to call the functions in the main.lua. I know lua I just don’t know the love version of it.
Hmmm am I missing something? Followed up to the point of drawing the rectangle but nothing showed up, just a blank black screen and no error even with console = true, no console window popped up on Mac. And yes, main.lua file has the Player functions inserted as taught.
Also tested with a previous Love2d version on replit with the same blank screen result.
Any advise? :) Thanks for the tutorials!
Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord or alternatively email :)
what does attempt to index global 'Player' (A nill value) mean
Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord 🙂
Help! My Player Wont Move Infinitely, it only moves a couple of pixels before its not moving!
I would love to help, but I need to see your code . Send it with google drive or pastebin 👍
@@DevJeeper never mind! i just did some weird things which caused it too, btw this tutorial helped me make a space game in love2d
Thanks for letting me know, and good job on solving it yourself. Awesome to hear that you used the videos to create something entirely different on your own! I would love to try it out if you want to share it :)
Is it OOP in Lua ? "Self", reminds me Python language.
Technically there is no object oriented programming in Lua since there are no "real objects". However, lua gives you all of the tools to emulate it. Colon simply passes the table as an argument which is named self. You could get the exact same result by doing:
function Player.printHealth(self)
print(self.hp)
end
and then calling it:
Player.printHealth(Player)
or
Player:printHealth()
Hello, first of all, thank you so much for this tutorial! Glad to found a 'lua' tutorials for beginner like me. Thanks :)
.
By the way, I have some questions regarding the functions inside the Player:update function
this code:
---
function Player:move(dt)
if love.keyboard.isDown("w") then
self.y = self.y - self.speed * dt
elseif love.keyboard.isDown("s") then
self.y = self.y + self.speed * dt
end
end
---
1. First question is, can you (or maybe someone) explain the logic? I could not understand this function. I know that the self.y is the coordinate of the player in regards to y axis (CMIIW) and self.speed is how fast the player move on pixel/second (CMIIW).
but how does this two (self.y and self.speed) make the player move up and down when there is no definition of direction within the function (like self.y + 300 or self.y -300)? I hope my question makes sense :)
i just can't understand how that 20x100 white box could move up and down, when only it self.y (coordinate) and self.speed (speed) use in the function without actually determine the direction of the movement in the y axis (like -y or +y)?
would be really helpfull if someone could elaborate, i want to include this in the comment of the code. thanks again.
self.y is set to self.y minus or plus the speed. Since speed is just a number, it simply decreases or increases the y position :)
@@DevJeeper Oh, so in other words, self.speed is the one that determine the direction of the movement of the box in y axis in the code:
self.y = self.y - self.speed * dt
? Thanks for the answer!
Correct, there you subtract it, meaning it goes up. If you did + self.speed it would go down
@@DevJeeper thanks for the explanation :)
.
also thanks for all the efforts in making lua-love2D tutorials :) it helped me a lot in learning lua and also in programming :))
how can i put highscore ?
Sorry for the late reply, I have added it to my todo-list and will cover it in a future video!
Quite late to this but the big problem i have right now is that the object wont move
If you send me your code (Preferably through Discord or mail) I will help you out! :)
the white tile dosent appear
why my letters dont have colors like yours?
I made a gif for you which hopefully explains it: gyazo.com/a826070355e7b306f92366e7c7aaa594
Let me know if you need any further help :D
I've copied your code exactly and I'm getting the error "player.lua:21: attempt to perform arithmetic on local 'dt' (a nil value)". The only way to fix this is to take out dt in the line "self.y = self.y - self.speed * dt" but obviously that isn't ideal. Is there any way I can fix this?
For me to be able to say what the reason is with certainty I need to see your code. The error code allows to make a couple of guesses though.
First of all, the problem is that “dt” is equal to nil, meaning it’s not available in the scope of the function. My best guess is that you either forgot to include “dt” as an argument when calling the function, or in the function itself. Alternatively you use a colon in the function but a dot when you call it.
If neither of these are the cause then I need to see the code to help you.
@@DevJeeper i.imgur.com/a23udeK.png here's a link to a snapshot of my code. I'm sure its identical to yours
It would go faster if you included the full code, there are multiple different things that could be wrong. Now right now the most likely reason is that you called "Player:update()" in the main.lua file, omitting to pass "dt".
@@DevJeeper That is actually exactly it thank you so much. Comparing my code to yours was like the most annoying game of spot the difference haha
@@snakelele4148 You are most welcome! Getting an error with "dt" being nil is actually a fairly common thing, because it's very easy to miss passing it somewhere in the chain.
To fix it one should do what we just did, start from where the crash occurs and work your way backwards to love.update; double checking that dt is passed along each step of the way.
I cant see the rectangle, i think it could be the colour? I will try and see again
Did you manage to sort it out? :)
@@DevJeeper yes, thanks, there was a comment further down that asked. I forgot to call the functions in main.lua
@@toastersunited Great, well done for sorting it out! :)
It is good but, why should one use lua over other game engines, which give you a nice interface, animation capabilities, and all...??
Lua is a programming language, Löve is a framework.
Frameworks are more lightweight than an engine such as unity. I prefer Löve since it allows me to write the entire structure myself, I love the fact that you make a new project by literally just creating a new folder. There are also libraries that you can use for common things such as animations and gui.
for some reason, the script doesn't work.. i typed it out and everything, i understand it too.. i also tried copy and pasting from the link in the description with no success. i've saved the script as well. could you please help? loving the series btw! you've earned a sub
I would love to help! However I need you to link me your code (preferably on pastebin or google drive) and tell me a little bit more about what it is that doesn’t work.
@@DevJeeper pastebin.com/wqaL8Hfc
@@DevJeeper actually, i believe i found the problem for the rectangle drawing out part. i did "function Player:draw()" instead of "function love.draw()". would this work the same?
Your main file seems to be empty, apart from the require of the player file. You need to indeed declare love.load, update & draw there. Then you should call the players functions there. This is something which I cover in the video so if you feel uncertain I suggest rewatching it :)
Let me know if you need more help or pointers and I will do my best to help you :D
@@DevJeeper appreciate the help! :D
idk why but the rectangle doenst appear even though i did every thing like you. plz help.
Also your video is awesome
Hey there! Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord or alternatively email :)
@@DevJeeper sorry i was dumb enough to forgot to put the Player:draw(), Player:update(dt) and Player.load() in the main .lua functions.
But when i did this its give me this error code:
Error
main.lua:4: attempt to index global 'Player' (a nil value)
Traceback
[love "callbacks.lua"]:228: in function 'handler'
main.lua:4: in function 'load'
[love "callbacks.lua"]:136: in function
[C]: in function 'xpcall'
[C]: in function 'xpcall'
@@chillingbird8212 Sorry but I still need to actually see the code in order to help you!
@@DevJeeper srry i was dumb enough to put local before Player = {}
You are not dumb! Making mistakes is part of programming, everyone makes them. Finding them and fixing is just part of the game :)
Well done for figuring it out your self!
what is the run.bat file for?
if you double click it, it will run the game. Small quality of life thing. Another option is to setup your IDE/Editor to do it for you.
2:27 pretty much same as on Roblox...
Yeah for people with any kind of game development experience this will feel quite natural (as it's very common). However, people who don't have that will usually think of the Y-axis flipped to this, since this is more common in other areas.
I already have a love-hate relationship with lua. It's giving me an error saying:
Error
player.lua:5: attempt to call field 'getheight' (a nil value)
Traceback
player.lua:5: in function 'load'
main.lua:4: in function 'load'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
And I don't fully understand it at all. Even if I copy the parts from your github project into a new project it doesn't work, so I can't even get past the part where the engine draws a rectangle
The problem is "getheight'", it should be camelCased - "getHeight" Let me know if you need any further help :)
why is this get a error?
it prints weird shape help!
Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord 🙂
this is a great tutorial, but please slow down at some parts. It's really hard to follow and I made a lot of simple mistakes.
Thank you for the feedback!
I haven't played around with stuff like "self" before : p
While it isn't really needed in this tutorial, it's really good to get used to using "self" since it kind of is a cornerstone when you start coding object oriented.
@@DevJeeper I do have it so tables have their own functions that get called later like:
t={}
t.draw=drawtri
-- later ...
for i=1,#tri do
t=tri[i]
t:draw()
end
So I kinda do something like that?
Yeah you could say it's kinda like that :)
The the next tutorial series (after Pong) will be focused on more object oriented programming. I will try my best to explain in in detail then!
yes yes yes yes yes yes
This is a great tutorial for both Lua and love2d, but after you start dividing thing in different functions, my syntax isn't right anymore. And could you please use comments? It makes things easier when i see this project again after 2 months.
Error
Syntax error: main.lua:22: function arguments expected near 'end'
Traceback
[C]: at 0x010a70db20
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
some more information:
function Player:update(dt)
Hey there, thank you for the kind words!
I have added a link in the description to this episodes code, and I have gone ahead and commented it. The reason I don't comment code during the tutorial is best for your learning to make your own comments. I will explain the code, and then you can put it down with your own words. Now when it comes to your error, it's very difficult for me to know what your problem is, because error messages only tell me where in your code there is an issue, not necessarily what it is. If you could send me your code, I will have a look at it and help you figure out the problem!
Thank you for the feedback, I have had some people say its too fast (and some that thought it was too slow), but I will keep it in mind for the next tutorial series! :)
@@DevJeeper Thank you, you're one of the first person with coding tutorials that actually responds to questions.
I put some additional code in there about moving, and it worked before the function switching. I don't know what went wrong, but i started over from your code and now it works again.
@@marn200 Awesome that you managed to sort it out yourself! It's very often small mistakes that are easy to make, but difficult to find. I do plan to continue responding to all comments, so I'm glad to hear it's appreciated! :)
@@DevJeeper ive copied your code but then this error happens again?
@@skytheambatablow Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord 🙂
ö
From the VERY START of this video I can tell the title of this video is false and a game is not created in "3 easy steps". It's more like 12 to 20 easy steps including; listening to different sets of instructions. If such a game were made in 3 easy steps, easily and only in the 3 steps only, you would not still be reading this comment here, you would have already created a new game to completion.
I’m assuming your joking, but on the off-chance that you are serious:
The series is split into 3 parts: Making the player, making the ball and making the opponent paddle.
I have done my best to simplify the logic as much as possible and keep the videos short. I’m sorry if you found it too difficult, this was the first series I made :)
Feel free to come with some feedback on parts you feel where not explained enough!
Thank you for a very awesome tutorial! Its just that when I run it it says this
Error
player.lua:1: attempt to call global 'player' (a nil value)
Traceback
[love "callbacks.lua"]:228: in function 'handler'
player.lua:1: in main chunk
[C]: in function 'require'
main.lua:1: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
Can you please reply and help me on this?
Thank you
Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord or alternatively email :)
When I try this it just tells me "Error
Syntax error: main.lua:3: '=' expected near 'love'
Traceback
[C]: at 0x613dd550
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'"
I need to see what ”this” is :D
Could you send me a link to your project and I will have a look & help you figure it out. RUclips deletes a lot of comments with links, so the best would be through Discord or alternatively email :)
Main.lua:4 attempt to index global "Player" a nil value
"Hey you said Player, but it doesn't exist" -> Maybe you named it player with lowercase?
I don't understand why this is happening. Any help would be appreciated.
Error
player.lua:29: attempt to index local 'self' (a nil value)
Traceback
[love "callbacks.lua"]:228: in function 'handler'
player.lua:29: in function 'checkBoundaries'
player.lua:16: in function 'update'
main.lua:9: in function 'update'
[love "callbacks.lua"]:162: in function
[C]: in function 'xpcall'
I can make a guess, you forgot to use a : when declaring or calling the 'checkBoundaries' function. For example typing Player.checkBoundaries instead of Player:checkBoundaries.
If that is not the case, then I will need to see your code to help you figure it out.
I refuse to use love because naming your language love is stupid and I would feel stupid using it.
The programming language is named ”Lua”. The framework is named ”Löve”. I’d say you should choose based on other factors than names, but you do you!
if have problemms getting deldta time us this
something * love.timer.getDelta()
-guy from stackoverflow thx a lot almost had a heart attack
No, you shouldn't do that (at least not for the purpose that you are doing it).
If you are "having problems getting delta time", then it is because you are forgetting to pass it along, or forgetting to declare the argument. Instead of making a "dirty hack" to get it to work, you should remove it and search for the error you made. If you want help finding it you can join the discord server and post your code there!
@@DevJeeper "dirty hack?" also yes itry what you siad just cound'nt find any info online
@@DevJeeper also link to discord pls
@@therealrgb2354 discord.gg/mUaVASvG4z