I just discovered I had magical powers. A couple of days ago I was thinking "Man, I need to learn Lua... I wish Derek made one of his "learn X in an hour" videos. I wonder what else I can make happen...
30:11 Just a note: after fiddling around with this, I've come to the conclusion that the caret (^) actually denotes NOT when it is the first character in the brackets. So [^%s] means character that is NOT a space. The brackets themselves group the character search together, so [^%A%s]+ would be a pattern that matches characters that are NOT a non-alphabetic character or space, while + keeps matching the search as much as it can until returned nil! :)
Any time I goto youtube and search for an item and see that it's by "Derek Banas" I immediately select it. These presentation are precise, well explained and accurate. I have NEVER been disappointed.
This is the perfect tutorial for anyone who is already familiar with a language and can keep up. It is refreshing to have a tutorial that dives straight in and lets me know what I need, and provides a cheat sheet. Fantastic! Well Done and Thank you!!!
Great tutorial, thank you! Not sure if pointed out already, but you have 5%3 instead of 5.2%3 at 7:10, which is why you get 2 instead of 2.2 . 5.2%3 gives 2.2 in Lua.
I love the fast pace of your video. I just wanted a quick overview and this delivers. Your presentation is clear and accurate. Your video was posted 6 years ago and I just found it! Cheers and thank you very much.
i'm watching this this video in 2022 and it is still perfect. no need to watch 10 hour long videos if you already understand programming and or know other languages
A linguagem que me enche de orgulho, apesar de nós brasileiros sermos muito explorados, existem muitas pessoas inteligentes nesse país Lua é só mais um exemplo disso, não podemos desvalorizar essas pessoas, e não podemos viver nas sombras dos países desenvolvidos temos que encontrar nosso próprio caminho, porque somos todos iguais, um dia ainda veremos nosso país brilhar.
4:33 The precision of floating point numbers decreases as their value increases. That's why they are FLOATING point. Try this: a = 9999999999999.0001 b = a + 0.0001 print(b == a) This prints true. You don't have 13 digits of precision.
Scripting languages always creeps me out... not pre-defining variable types and not having to use curly brackets and semicolons feels really strange to me. Really awesome tutorial tough, I really like the speed especially for someone that already has a basic understanding of programming, since the basics are often very similar to other programming languages.
is it just me, or is this one of the most fun and beginner friendly languages out there? it is so "readable", it really gives the sense of talking to the computer, so much fun. it must be great to teach programming. idk it's so cute like "if this is true then do this" lol.
This was a fantastic video. To those complaining about the speed, I really enjoy the no BS pace, and I paused after each section to work thru the code myself and see it in action on my machine.
I know this video's old, but just want to point out: your OOP example doesn't work! It works for a single instance of that object, but not for consecutive instances. If you create a second Animal, then BOTH animals will have the exact same values, as it basically just creates two aliases to the global Animal object. This is because inside the constructor, "self" is referring to the global instance of Animal, not the new instance. The constructor needs to create a new table, assign "self" (the global Animal table) as its metatable index, and then return that new table. Your setmetatable() method at the beginning is a no-op, it does nothing without capturing its result into a variable. Here's a working example: function Animal:new(height, weight, name, sound) newAnimal = setmetatable({}, { __index = self }) newAnimal.height = height newAnimal.weight = weight newAnimal.name = name newAnimal.sound = sound return newAnimal end
I can't thank you enough for all your videos. Your approach on topics, the way you make it all look like a piece of cake is amazing. I'm just so happy I've find your channel, and yours is the only one I get notifications on upload. Thanks a bunch.
Great and straight-to-the point tutorial! I just have a couple of questions: 15:50 "age > 13 and true or false" | What is actually happening here? How does this work? 33:38 "for k, v in pairs{...} do" | What is k and what is pairs? Where are they defined?
1. As he said, it looks like a ternary operator, so equivalent of this will be like: if (age > 18) { canvote = true; } else { canvote = false; } 2. Seems like pairs{} is an operator, and three dots is a function parameter above.
Soooo, I can say that, I'm 85% done with this tutorial. As in, I followed along with the video and cheat sheet, ran all the code, tried different things with it, and followed up with lua documentation when I wanted to know more. This is a really great tutorial. I'm still getting the hang of loops, closures, and fucntions, but I'll get there. After this one, I'm going to go for Julia, Clojure, Rust, and F#. Hopefully, soon, I'll know 10 different programming languages. "If I can do it, anyone can." -Derek Banas After that, I'm going to complete the data science and math videos. I'm currently learning this stuff solely to stay sharp. Perhaps some time in the future, it'll all come together and I'll know what to do with the knowledge. Until then, I"m just happy learning.
I love learning new things everyday as well. That great thing is that once you learn data science you’ll see the world in all new ways. All of a sudden that which was once confusing will now make sense. It is almost like being able to see you future.
Thank you for not getting lost in scientific web machine code language when explaining all of these methods, objects, tables, functions and modules. Super easy to understand. This was the best explanation on lua meta-tables I have found on the web. Awesome job
great tutorial. One thing though the inheritance isn't quite OO. Typical in an OO language your descendant class would not need to define all the class members, you could simply call the inherited constructor and then simply add anything you wanted, so in your example the favfood for the cat is would you need to add.
Yeah, I came to the comments looking for an answer for this. Is it safe to assume that inheritance can be achieved by calling Animal:new() inside Cat's constructor, then adding any additional Cat functionality, and returning the extended Animal table?
Nice, By the way If you are totally new to programing, and never used any type of language, here is the list of languages to learn in order!; Python - Easy to learn is similar to others - 1 Lua - Nice, and powerful and easy to understand if you learned a mother language - 2 Java - well, this is a popular game language but just get to under stand it and you will be good ;) - 3 1/2 C# - A very popular game language ProIsh language... You can easily find a job with this one its also very complex, but once you get use to it you will be in love with this one - 4 Language of Choice - NICE, you are a pro now, Have fun make some money or have a useful hobby! - 5
No programming language(except Python) suits me nor it is easy to me. Java and C+(And it's brothers) eats my brain off. I tried Ruby because it is like the best and easiest static language but it also confuse me. so guess what, I will stick to my Python and possibly do AI interaction. Edit: I accidently typed Ruby instead of Rust.
Thanks for the great tutorial! One minor issue @~32:42: The extra 'nil' value printed is because at the very end of our loop, we've accessed an index that doesn't exist in 'splitStrTable'. If we modify line 10 to start i at 0, this problem goes away.
***** I think so. It's a pretty weird language for me as well, but you just need some time to get familiar with the "alien" side of it and you're ready to go.
One of the features I like from Lua is that is tolerate various coding practices. For example, no need to adhere to indentation convention, whitespacing, etc. And in this video Derek used camelCase and not underscore_naming practice. Which reminds me of the Pascal programming language! Maybe Lua is Pascal's case-sensitive version (but without semicolons)!!
31:25 the total number of words should be “i-1”, instead of i, since you did “i=i+1” at the end of each loop. That’s also the reason you got the last line output of “nil” when you tried to print out each word.
If I'm not mistaken, if you put your timestamps before the chapter title, youtube will show them on the progressbar in the player. (So formatted like: 23:24 Chapter name instead of Chapter name 23:24 )
I wonder why nobody pointed out the mistake at 31:20? You should switch lines 13 and 14, and change line 10 to "local = 0" to make the function really return the number of words. That is the reason you have to fix the loop later on by subtracting 1 from numOfStr... 32:44: there is not always am extra nil. It means you accessed an uninitialized element in the table... But other than that, I really liked the video! The speed is just perfect!
Great tutorial, although I think it's confusing to compare Lua tables to arrays - they are more like mappings or Python dictionaries. The info about metatables is really useful. Thanks!
Thank you for making a no nonsense video. It is refreshing to have information without all the extra junk and funk everyone puts into tutorials. THANK YOU.
This was a great tutorial, it taught me a lot about LUA so thank you :) I do have one question tho and that's at the end when you started talking about pseudo-OOP with LUA, you initially defined the "Animal" table with default values (height, weight, etc) and then used that as your metatable in the initialization function for your Animal object, but then later when making the Cat object you were able to pass a different value (favFood) through the previously inherited metatable without it having a default value already defined within it. So my question is why is it necessary to set up your initial metatable with default values if you're able to add values in on the fly?
I know diss commentary is old but, if you do put the setmetatable in the beginning , i know... you can also charge the values on the fly, but you can use the values you didn't change to use them to be part of the class itself, diss what we call static values , you can use diss for some cool stuff like count how many instances of the class you have , you can modify a value based on certain instances and other cool and useful things.
I am pretty sure he did that only to show you a reference as to what is going to be in the table. defining it up front is not necessary. Just being repetitive to show you what is in it.
open SciTE, not the command prompt thing if you haven't already. That's your IDE. Click view and select output for a place where the output can show and you need to save a script before you can run it.
EDIT: This issue was addressed and resolved, I finished the video, I think it was great! Quick way to understand Lua and syntax for people that already understand programming concepts and coming from other languages. -Made it to 14 min in, I enjoyed it actually, however, after 4 ad rolls in under 15 min, I am not going to keep watching this, I suggest you edit your ad rolls.-
@@derekbanas I appreciate that, I am going to finish it then. ;) Also, I didn't mean you needed to shut off all of them, I would have been fine with say every 10 min or so. It was just overboard before. Thank you!
If you put a 0:00 at the beginning of the timestamps and the time in front of the title like this: Data Types 3:43 -> 3:43 Data Types You get nice chapters in the timeline
If you're having trouble installing Lua, here's how I did it: Install Lua 5.1.4 here. code.google.com/archive/p/luaforwindows/downloads. Yoiu can then run that version of Lua in your command line. On your pc, look up "cmd". Open that up and then type "lua". You can now write Lua code :) If you want to use an IDE then I recommend downloading an IDE called ZeroBrane Studio. That's what I'm using at the moment and it's working decently well. Hope that helps. It's definitely a frustrating experience doing it the "right" way. Let me know if you need any help!
+Oliver Benson Thank you for helping :) I downloaded using the sources I showed in the video. You may have to put lua in your path if you are on Windows. Maybe that was the problem people were having?
+Derek Banas Hi Derek. Thanks for replying. That's how I did it as well. However on www.lua.org/download.html you can download version 5.3.2 which I had a lot of trouble downloading. Got there in the end though and just did it the way you did! The other question I have is how I can get the same software you're using. What I mean is on my pc, I'm using Windows 10. I can program in Lua on the cmd, but I'd prefer programming in the same format you are i.e. use Sublime Text (which I've heard it pretty good) and the terminal. I'm not sure how to go about doing that though. I hope that makes sense and you can help me out. Thanks for all the videos you make!
+Oliver Benson Sublime Text works on every OS and you can get it here www.sublimetext.com/3 If you want a free IDE that is almost exactly the same take a look at Atom atom.io/ Yes you can use your command line just like I use the terminal. Everything works pretty much the same. I hope that helps :)
+Derek Banas Do you know a way of downloading the latest version because my pc doesn't seem able to open tar.gz files? Thanks for recommending Atom :) Is the terminal the same thing as the command line? It's just I don't quite understand it. How do I get Sublime Text to interact with the terminal?
+Oliver Benson You can use the install program on Windows for Atom and Sublime text. You don't need the tar file. I just recompile in the terminal. You can run the terminal in both IDEs, but I have never done that.
Thanks, I didn't know a thing about Lua, but it's quite simple. Not a complicated language at all. That said, I wished you had picked better examples. For instance the first table at 25:30 is confusing to me because you kept using index 1. What is confusing is that we don't know if there is an element zero at all, and if so why it's not reported in the length calculation. A bit more explanations of what actually happens to index zero would have been very useful. As it turns out there is an element zero and it contains nil (I've checked). And the other issue is at 31:30 when you return the wrong number of words (one too many), but when you get an extra "nil" you then explain it by saying that tables are always nil-terminated, which isn't true at all (I've checked too). Barring those two confusing points (well the second is real easy to spot to someone with programming experience), the pace is good and the content is really practical. Thanks again.
No, there is no element 0. All tables in Lua start with an index of 1. The only reason you are getting nil is simply because it doesn't exist. And, also, all tables really should be nil-terminated. If your result showed that to be false, then please explain what you did to test it because I would love to know how that could be possible.
omg! first of all thank you! most videos just throwed me to the os x website and I did complete a mess because I did not understood what was wrong. It's really important to mention as much system as possible so the viewers could actually understand and follow and understand. Thank you so much!
Well, it's kind of dumb if anyone expects that a >1 hour tutorial will cover basic programming fundamentals. All of Derek's crash courses focus on syntax, not basic programming fundamentals
@@yegorgribenuke6853 Look at a different tutorial mate. These tutorials are aimed for programmers meaning you should know how to program as in basics fundamentals of programming. These crash courses are literally him teaching you the syntax of a language I come from C++ so all of this is really easy to understand. I don't want to watch a Lua tutorial that explains to me what functions, loops, selections and so on are I already know what they are. Am here to learn the syntax of this scripting language.
@@설리-o2w they teached us Pascal as programming language for us understand others. I understand how it works, i do not know any commands and any functions, thats my problem!
I can only imagine how frustrating it would be to not have any programming experience and watch this video, lol. I love that you did it for an audience of people with experience, as I do not have to waste an extra 5 or so hours on some slowpoke course lol.
Lmao I was expecting a "Explain it to me like I'm Five" kind of tutorial, still helpful since I briefly do Python and Java Script in Highschool and tried Roblox lua on my own before actual lua. So "some experience" lol
@@derekbanas I know zero code, I'm 14 years old, have never coded past scratch junior no matter how my parents encouraged me from ages 6-10. To say I am lost watching this video is an understatement 💀
Good video. Lua quirks: arrays & strings index from 1, not 0. Your ternary example with booleans is misleading "foo = (condition) and true or false" as that is identical to "foo = condition" Better example, showing wierd Lua quirk, would be: age = 13 foo = (age
Correction: around 7:20, the claim was made that the modulus operator "automatically cuts off" decimals, but the actual code being ran did not include a decimal -- only the string portion describing the operation had the decimal. As of Lua 5.1, executing `5.2 % 3` will give the result 2.2, not just the integer portion.
Derek Banas First off; very nice video; as always. I really enjoy your stuff and I think it's all really awesome. One small thing with a big impact I had to point out though: In the 'OO' section of this video; you're constructors are wrong in a very subtle way. The way you wrote it; your X:new()'s are simply modifying the existing table and returning it. You can check this by simply making two Animal `objects` and comparing them with ==; same goes for two Cat `objects`. I've written the necessary changes together with a few explanations here: paste.ubuntu.com/11793664/ Again, I very much love your videos, and very subtle mistakes like these are perfectly natural. Pitching in a little hand is the very least I could do. Thanks again for all the great content; you rock! Nashwan.
The reason that 9223372036854775807 is the largest number you can hold is because this number is the 64 bit integer limit. 64 bit programs simply cannot hold more data than that. The only way to display a higher number than this is by using a string and not an integer
This is crazy. I searched for 9.2 quintillion and the first result was that the odds of successfully choosing a perfect NCAA March Madness bracket are 1 in 9,223,372,036,854,775,808. exactly one digit higher than the highest number you can go in Lua. Turns out that number is an even composite number. It is composed of a single prime number (in this case two) multiplied by itself sixty-two times.
Well, if you have NO knowledge of programming, learning Lua is still going to be helpful in terms of some syntax and things. And on the plus side, knowing any programming language makes it easier to transition to a new one, Lua or not.
@@neurofiedyamato8763 As a Roblox Developer, the syntax on roblox is so watered down that they just use a base of LUA and add their own functions entirely.
Just started coding about 3 months ago. This video is way to fast for me to understand anything. I believe this is for people who have coded in other languages before Corona. I will come back and listen again when I have more understanding.
L0gicz The difference is that io.write adds text to the most recently used line while print creates a new line Example: for I=1,4 do io.write(“cool”) End Terminal: coolcoolcoolcool Example: For I=1,4 do Print(“cool”) End Terminal: Cool Cool Cool Cool
Well it's good for making text matrixies if you arnt using a 2d engine. example: for r=1,5 do print("") for i=1,5 do io.write(" 0 ") end end terminal: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 --If you used varibles instead of text you could set each point to something other than " 0 "
Ok, now you've officially beat Darth Vader as the most inspirational person on youtube! Thanks for your dedication, and if you had time unity3d.. been developing a game on android thanks to your tutorials, then decided to switch to unity, and for 2 weeks been digging in da' documentation...suuucks. Keep them coming, and Lynda should hire you!
Derek Banas:So its mostly used for things related games, simulators , etc isn't it ? But one thing that surprised me is its use in robotics,so I got one reason there to learn it.Thanks for uploading.
This seems to be really simple so far! This is coming from someone who barely remembers python and is much more used to block coding in engines, but I'm looking into Lua for a certain engine.
Learn in One Videos for Every Programming Language
Subscribe to Bookmark them: bit.ly/2FWQZTx
C++ : ruclips.net/video/Rub-JsjMhWY/видео.html
Python : ruclips.net/video/N4mEzFDjqtA/видео.html
Java : ruclips.net/video/n-xAqcBCws4/видео.html
PHP : ruclips.net/video/7TF00hJI78Y/видео.html
MySQL : ruclips.net/video/yPu6qV5byu4/видео.html
JavaScript : ruclips.net/video/fju9ii8YsGs/видео.html
C# : ruclips.net/video/lisiwUZJXqQ/видео.html
HTML5 : ruclips.net/video/kDyJN7qQETA/видео.html
CSS3 : ruclips.net/video/CUxH_rWSI1k/видео.html
JQuery : ruclips.net/video/BWXggB-T1jQ/видео.html
TypeScript : ruclips.net/video/-PR_XqW9JJU/видео.html
ECMAScript : ruclips.net/video/Jakoi0G8lBg/видео.html
Swift : ruclips.net/video/dKaojOZ-az8/видео.html
R : ruclips.net/video/s3FozVfd7q4/видео.html
Haskell : ruclips.net/video/02_H3LjqMr8/видео.html
Handlebars : ruclips.net/video/4HuAnM6b2d8/видео.html
Bootstrap : ruclips.net/video/gqOEoUR5RHg/видео.html
Rust : ruclips.net/video/U1EFgCNLDB8/видео.html
Matlab : ruclips.net/video/NSSTkkKRabI/видео.html
Arduino : ruclips.net/video/QO_Jlz1qpDw/видео.html
Crystal : ruclips.net/video/DxFP-Wjqtsc/видео.html
Emacs : ruclips.net/video/Iagbv974GlQ/видео.html
Clojure : ruclips.net/video/ciGyHkDuPAE/видео.html
Shell : ruclips.net/video/hwrnmQumtPw/видео.html
Perl : ruclips.net/video/WEghIXs8F6c/видео.html
Perl6 : ruclips.net/video/l0zPwhgWTgM/видео.html
Elixir : ruclips.net/video/pBNOavRoNL0/видео.html
D : ruclips.net/video/rwZFTnf9bDU/видео.html
Fortran : ruclips.net/video/__2UgFNYgf8/видео.html
LaTeX : ruclips.net/video/VhmkLrOjLsw/видео.html
F# : ruclips.net/video/c7eNDJN758U/видео.html
Kotlin : ruclips.net/video/H_oGi8uuDpA/видео.html
Erlang : ruclips.net/video/IEhwc2q1zG4/видео.html
Groovy : ruclips.net/video/B98jc8hdu9g/видео.html
Scala : ruclips.net/video/DzFt0YkZo8M/видео.html
Lua : ruclips.net/video/iMacxZQMPXs/видео.html
Ruby : ruclips.net/video/Dji9ALCgfpM/видео.html
Go : ruclips.net/video/CF9S4QZuV30/видео.html
Objective C : ruclips.net/video/5esQqZIJ83g/видео.html
Prolog : ruclips.net/video/SykxWpFwMGs/видео.html
LISP : ruclips.net/video/ymSq4wHrqyU/видео.html
Express : ruclips.net/video/xDCKcNBFsuI/видео.html
Jade : ruclips.net/video/l5AXcXAP4r8/видео.html
Sass : ruclips.net/video/wz3kElLbEHE/видео.html
Thx dude
OMG YOU KNOW SO MUCH ABOUT SCRITING
I just found a gold mine, thanks dude.
What software are you using?
How do you know all of this...
Data Types 3:43
Math 6:58
Conditionals 10:53
Ternary Operator 15:20
Strings 16:35
Looping 19:11
Repeat Until 20:44
User Input 20:56
For 22:00
For In 22:29
Tables 23:41
Functions 28:26
Return Multiple Values 29:25
Variadic Functions 33:13
Closure 34:27
Coroutines 36:46
File I/O 40:10
Modules 43:32
Metatables 45:30
OOP 51:00
Inheritance 55:04
You got it from the description
O o p
@@AxmPlays Some people don't read the description
nice
up
I just discovered I had magical powers. A couple of days ago I was thinking "Man, I need to learn Lua... I wish Derek made one of his "learn X in an hour" videos. I wonder what else I can make happen...
***** That's funny :) I'm wondering what my puppet master will have me do next?
***** Actually, I think you need more people to cast this spell/ritual, since I also thought of this :)
+Gray Fox Make my dad win the lottery. For 1 million dollars.
make me will lottery
Gray Fox I
30:11 Just a note: after fiddling around with this, I've come to the conclusion that the caret (^) actually denotes NOT when it is the first character in the brackets. So [^%s] means character that is NOT a space.
The brackets themselves group the character search together, so [^%A%s]+ would be a pattern that matches characters that are NOT a non-alphabetic character or space, while + keeps matching the search as much as it can until returned nil! :)
Any time I goto youtube and search for an item and see that it's by "Derek Banas" I immediately select it. These presentation are precise, well explained and accurate. I have NEVER been disappointed.
This is the perfect tutorial for anyone who is already familiar with a language and can keep up. It is refreshing to have a tutorial that dives straight in and lets me know what I need, and provides a cheat sheet. Fantastic! Well Done and Thank you!!!
Thank you :) I'm happy it was useful
Yes indeed!
I'm just commenting so I remember where I was: 14:20
420
Same 13:02
19:21
Did you learn lua?
@@faint.2396 yes, its super table based, oop is fun
Great tutorial, thank you! Not sure if pointed out already, but you have 5%3 instead of 5.2%3 at 7:10, which is why you get 2 instead of 2.2 . 5.2%3 gives 2.2 in Lua.
Thank you :) Thank you for pointing out my error and for explaining the results for others that may have been confused.
that's explaining! man I'm still confused XD
he means that % is a remainder in lua so 5.2%3 will returnm 2.2 because its the remainder from 5 / 3
he means that % is a remainder in lua so 5.2%3 will returnm 2.2 because its the remainder from 5 / 3
Sublime Text
I love the fast pace of your video. I just wanted a quick overview and this delivers. Your presentation is clear and accurate. Your video was posted 6 years ago and I just found it! Cheers and thank you very much.
i'm watching this this video in 2022 and it is still perfect. no need to watch 10 hour long videos if you already understand programming and or know other languages
Thank you for taking the time to tell me you like them :)
This is great, I love how your explanation goes in depth enough and at a very nice rate, not too fast, not too slow :)
A linguagem que me enche de orgulho, apesar de nós brasileiros sermos muito explorados, existem muitas pessoas inteligentes nesse país Lua é só mais um exemplo disso, não podemos desvalorizar essas pessoas, e não podemos viver nas sombras dos países desenvolvidos temos que encontrar nosso próprio caminho, porque somos todos iguais, um dia ainda veremos nosso país brilhar.
Seu nome deixa o comentario melhor ainda. KKK
@@warx1680 psé
Po ... eh tiquo
isso dificilmente vai acontecer com o D.I.T e o imperialismo
I was trying to code but this one coding language keeps kicking my ass.
Keep at it and you'll get it :)
The Language27 ?
Inari Kami Yeah, The Language27!
Some say that The Language27 is the first language that programmed itself and it was born from fire !
Inari Kami I heard The Language27 can code a chunk longer than a professional programmer!
The problem I keep having with learning LUA is that it’s so simple, I just don’t know what words to use.
what do you mean by word ?
NerdgineerTV Im pretty sure he meant he cant find out what to put in the procedures; parts of the procedures.
Yes ikr
becareful with caps and word
Doesn’t make sense. How can something “simple” be hard to learn
4:33
The precision of floating point numbers decreases as their value increases. That's why they are FLOATING point. Try this:
a = 9999999999999.0001
b = a + 0.0001
print(b == a)
This prints true. You don't have 13 digits of precision.
Scripting languages always creeps me out... not pre-defining variable types and not having to use curly brackets and semicolons feels really strange to me. Really awesome tutorial tough, I really like the speed especially for someone that already has a basic understanding of programming, since the basics are often very similar to other programming languages.
Yes they are something to get used to. I'm glad you found the video useful :)
hhhhjkk
Not pre defining variable types has little to do with the fact that it's a "scripting" language
@Nicholas Negron lua is basically just game configuration or modding not like game design
Look at python: no semicolon, no curly bracket. It is one of the most readable language
is it just me, or is this one of the most fun and beginner friendly languages out there? it is so "readable", it really gives the sense of talking to the computer, so much fun. it must be great to teach programming. idk it's so cute like "if this is true then do this" lol.
Lua is a fun language I agree
18:12 String indices in Lua start at 1.
Yes similar to R, thx for reminding again 😊
This was a fantastic video. To those complaining about the speed, I really enjoy the no BS pace, and I paused after each section to work thru the code myself and see it in action on my machine.
Thank you :) I'm happy it was useful
I know this video's old, but just want to point out: your OOP example doesn't work! It works for a single instance of that object, but not for consecutive instances. If you create a second Animal, then BOTH animals will have the exact same values, as it basically just creates two aliases to the global Animal object.
This is because inside the constructor, "self" is referring to the global instance of Animal, not the new instance. The constructor needs to create a new table, assign "self" (the global Animal table) as its metatable index, and then return that new table. Your setmetatable() method at the beginning is a no-op, it does nothing without capturing its result into a variable.
Here's a working example:
function Animal:new(height, weight, name, sound)
newAnimal = setmetatable({}, { __index = self })
newAnimal.height = height
newAnimal.weight = weight
newAnimal.name = name
newAnimal.sound = sound
return newAnimal
end
this should have more likes lol i guess not many people checked if it works? :p thanks for the correction @Josh.c
I rather pause to think and rewatch a fast paced video than to keep fast forwarding through bloat. This is gold.
I can't thank you enough for all your videos. Your approach on topics, the way you make it all look like a piece of cake is amazing. I'm just so happy I've find your channel, and yours is the only one I get notifications on upload. Thanks a bunch.
Mike Litorris Thank you for the nice compliments :) I'm very happy that you enjoy my channel.
Great and straight-to-the point tutorial! I just have a couple of questions:
15:50 "age > 13 and true or false" | What is actually happening here? How does this work?
33:38 "for k, v in pairs{...} do" | What is k and what is pairs? Where are they defined?
1. As he said, it looks like a ternary operator, so equivalent of this will be like:
if (age > 18)
{
canvote = true;
}
else
{
canvote = false;
}
2. Seems like pairs{} is an operator, and three dots is a function parameter above.
Game programming with lua is extremely easy
You mean scripting?
@@csongorkertesi976 yes
@@csongorkertesi976 Programming.
@@okandme You are right, you are *programming* my dude.
Can vouch, especially with Roblox and Love.
Soooo, I can say that, I'm 85% done with this tutorial. As in, I followed along with the video and cheat sheet, ran all the code, tried different things with it, and followed up with lua documentation when I wanted to know more. This is a really great tutorial. I'm still getting the hang of loops, closures, and fucntions, but I'll get there. After this one, I'm going to go for Julia, Clojure, Rust, and F#. Hopefully, soon, I'll know 10 different programming languages.
"If I can do it, anyone can."
-Derek Banas
After that, I'm going to complete the data science and math videos. I'm currently learning this stuff solely to stay sharp. Perhaps some time in the future, it'll all come together and I'll know what to do with the knowledge. Until then, I"m just happy learning.
I love learning new things everyday as well. That great thing is that once you learn data science you’ll see the world in all new ways. All of a sudden that which was once confusing will now make sense. It is almost like being able to see you future.
45:20 I think the answer in cm should be 365.760 cm. You used + instead of * in the convert.lua module. Anyway, great video!
Came here to say this. I'm glad I'm not the only one to catch it.
Thank you for not getting lost in scientific web machine code language when explaining all of these methods, objects, tables, functions and modules. Super easy to understand.
This was the best explanation on lua meta-tables I have found on the web.
Awesome job
Thank you very much :) Happy to be of help
great tutorial.
One thing though the inheritance isn't quite OO. Typical in an OO language your descendant class would not need to define all the class members, you could simply call the inherited constructor and then simply add anything you wanted, so in your example the favfood for the cat is would you need to add.
Yeah, I came to the comments looking for an answer for this.
Is it safe to assume that inheritance can be achieved by calling Animal:new() inside Cat's constructor, then adding any additional Cat functionality, and returning the extended Animal table?
Nice, By the way If you are totally new to programing, and never used any type of language, here is the list of languages to learn in order!;
Python - Easy to learn is similar to others - 1
Lua - Nice, and powerful and easy to understand if you learned a mother language - 2
Java - well, this is a popular game language but just get to under stand it and you will be good ;) - 3 1/2
C# - A very popular game language ProIsh language... You can easily find a job with this one its also very complex, but once you get use to it you will be in love with this one - 4
Language of Choice - NICE, you are a pro now, Have fun make some money or have a useful hobby! - 5
Me at 2:00 : “kinda similar to python“
Also me at 2:10 : "nope"
you can use print too
very similar to python except to oop & classes, but meta makes its work
haha
No programming language(except Python) suits me nor it is easy to me. Java and C+(And it's brothers) eats my brain off. I tried Ruby because it is like the best and easiest static language but it also confuse me. so guess what, I will stick to my Python and possibly do AI interaction.
Edit: I accidently typed Ruby instead of Rust.
@@primeroyal7434 Ruby is a dynamically typed language
It has been forever since I've watched Derek and when he said "Well hello internet", I felt that.
That's cool! Thanks for stopping back
Thanks for the great tutorial!
One minor issue @~32:42: The extra 'nil' value printed is because at the very end of our loop, we've accessed an index that doesn't exist in 'splitStrTable'. If we modify line 10 to start i at 0, this problem goes away.
Whoops sorry about that. Thanks for pointing that out for others :)
This, for me, is what I exactly need! It's straight to the point with no incessant talking! You are amazing, bro!
Thank you I did my best
How to you manage to learn so many languages?
+Max L. learning 1 language will make another 1 easy to learn
+Maximilian Lloyd If you learn C++ you can easily lean C#, Java, F# and even Python, *Lua*, Perl, Ruby ans so on
***** I think so. It's a pretty weird language for me as well, but you just need some time to get familiar with the "alien" side of it and you're ready to go.
***** Nah, it's not that complex, it's just confusing... Alright! know what? You win LOL
+Vededron use jQuery. They say it's better than JS. :)
This video is perfect for people who already know some other language and want to learn Lua.
10 Print "Hello world"
20 If inkey$ " " GoTo 40
30 GoTo 10
40 End
Run
What is that? I'm curious
@@martinnieva8484 BASIC
@@akira9449 Thank you very much!
Its like science dude. Like Quantum physic.
Lua is easier the basic
One of the features I like from Lua is that is tolerate various coding practices. For example, no need to adhere to indentation convention, whitespacing, etc. And in this video Derek used camelCase and not underscore_naming practice.
Which reminds me of the Pascal programming language! Maybe Lua is Pascal's case-sensitive version (but without semicolons)!!
Wow, thanks a lot for this very complete demonstration of lua's basics, it is a goldmine !
31:25 the total number of words should be “i-1”, instead of i, since you did “i=i+1” at the end of each loop. That’s also the reason you got the last line output of “nil” when you tried to print out each word.
If I'm not mistaken, if you put your timestamps before the chapter title, youtube will show them on the progressbar in the player.
(So formatted like:
23:24 Chapter name
instead of
Chapter name 23:24
)
I wonder why nobody pointed out the mistake at 31:20? You should switch lines 13 and 14, and change line 10 to "local = 0" to make the function really return the number of words.
That is the reason you have to fix the loop later on by subtracting 1 from numOfStr... 32:44: there is not always am extra nil. It means you accessed an uninitialized element in the table...
But other than that, I really liked the video! The speed is just perfect!
Thank you for pointing that out :) Sorry about the error
Great tutorial, although I think it's confusing to compare Lua tables to arrays - they are more like mappings or Python dictionaries. The info about metatables is really useful. Thanks!
Lua tables are hard to understand but can be much more logical and easy to use once you get familiar with them!!!
Thank you for making a no nonsense video. It is refreshing to have information without all the extra junk and funk everyone puts into tutorials. THANK YOU.
Thank you very much :) I'm happy you liked it
I had to see what I would use Lua for. It can be used for making World of Warcraft addons. Another great video Derek Banas
Allen Law Thank you :) Yes many people learn it just for that reason
Allen Law Corona SDK.
Checking it out Austin rau thank you
+PrankCentral Garry's Mod is what I seek to learn it for.
+Allen Law MTA:San Andreas,cocos 2d
Time goes by so fast. I watched this video around a month after it came out to help me learn it for roblox. I stopped playing roblox 4 years ago.
Jeez so u watched this 9 years ago
I was watching this video to learn lua so I can get better at using unitale... I can be a boss in it now :D thnx...
I'm very happy I helped :)
Same :D
Well done. High density. Nothing but pertinacity.
What a mouthful. Now, while this tutorial touched upon the very basic topics of lua, it's still a great tutorial and I appreciate your work!
Nice now I can spend rest of my life ricing AwesomeWM.
I was told I needed to learn Lua in a day for a client project and this really helped me nail the syntax and fundamentals down. Thanks!
That's great :) I'm happy it helped
This was a great tutorial, it taught me a lot about LUA so thank you :) I do have one question tho and that's at the end when you started talking about pseudo-OOP with LUA, you initially defined the "Animal" table with default values (height, weight, etc) and then used that as your metatable in the initialization function for your Animal object, but then later when making the Cat object you were able to pass a different value (favFood) through the previously inherited metatable without it having a default value already defined within it.
So my question is why is it necessary to set up your initial metatable with default values if you're able to add values in on the fly?
rule #1: "Lua not LUA"
lol little pedantic but ok ;) any thought on my question tho?
inheritance?
I know diss commentary is old but, if you do put the setmetatable in the beginning , i know... you can also charge the values on the fly, but you can use the values you didn't change to use them to be part of the class itself, diss what we call static values , you can use diss for some cool stuff like count how many instances of the class you have , you can modify a value based on certain instances and other cool and useful things.
I am pretty sure he did that only to show you a reference as to what is going to be in the table. defining it up front is not necessary. Just being repetitive to show you what is in it.
Absolutely loving the format (layout and speed). Fantastic stuff.
Thank you very much :)
wow! it's like having half a semester's classes in an hour lol. I learnt a lot thanks!
I try not to waste time :)
5.2 % 3 *IS* 2.2. Helps to evaluate the same expression as the text suggests.
I'm on windows and this looks a lot different then it does on mac, I can't even get the bar to come up
open SciTE, not the command prompt thing if you haven't already. That's your IDE. Click view and select output for a place where the output can show and you need to save a script before you can run it.
tried Viagra?
EDIT: This issue was addressed and resolved, I finished the video, I think it was great! Quick way to understand Lua and syntax for people that already understand programming concepts and coming from other languages.
-Made it to 14 min in, I enjoyed it actually, however, after 4 ad rolls in under 15 min, I am not going to keep watching this, I suggest you edit your ad rolls.-
Sorry about that. I normally only use one five second skippable ad. I switched it back.
@@derekbanas I appreciate that, I am going to finish it then. ;) Also, I didn't mean you needed to shut off all of them, I would have been fine with say every 10 min or so. It was just overboard before. Thank you!
I feel like I’m the only one here that isn’t here for roblox and is here because my teacher forced to class to learn LUA
Hi, so I'm here from a Minecraft mod.
LOL
Frosty Vex what is she a teacher for?
just btw you can say print("hi"); if you want to, lua will just yeet out the semi colon by itself
I think that means the end of a chunk (read the reference manual if you want to know what that is)
It feels so weard and wrong not to use '';'' in lua code :(
+Damien K Lots of languages don't conclude statements with semicolons, like Python and Ruby, to name a couple.
+Damien K It's honestly easier for me, lol. I for some reason have a hard time remembering to end every line.
I'm the opposite, I started off with Lua and once I've started C++, it felt unusual.
Well, if it confuses you that much just use it xD
and GML (game maker language)
If you put a 0:00 at the beginning of the timestamps and the time in front of the title like this:
Data Types 3:43 -> 3:43 Data Types
You get nice chapters in the timeline
@18:16
I thought lua starts with the index of 1 and not 0
it does start at 1
The index starts counting from 1 and not 0
"I changed my password".
Great fast tutorial 👍🏻
If you're having trouble installing Lua, here's how I did it:
Install Lua 5.1.4 here. code.google.com/archive/p/luaforwindows/downloads. Yoiu can then run that version of Lua in your command line. On your pc, look up "cmd". Open that up and then type "lua". You can now write Lua code :)
If you want to use an IDE then I recommend downloading an IDE called ZeroBrane Studio. That's what I'm using at the moment and it's working decently well. Hope that helps. It's definitely a frustrating experience doing it the "right" way. Let me know if you need any help!
+Oliver Benson Thank you for helping :) I downloaded using the sources I showed in the video. You may have to put lua in your path if you are on Windows. Maybe that was the problem people were having?
+Derek Banas Hi Derek. Thanks for replying. That's how I did it as well. However on www.lua.org/download.html you can download version 5.3.2 which I had a lot of trouble downloading. Got there in the end though and just did it the way you did! The other question I have is how I can get the same software you're using. What I mean is on my pc, I'm using Windows 10. I can program in Lua on the cmd, but I'd prefer programming in the same format you are i.e. use Sublime Text (which I've heard it pretty good) and the terminal. I'm not sure how to go about doing that though. I hope that makes sense and you can help me out. Thanks for all the videos you make!
+Oliver Benson Sublime Text works on every OS and you can get it here www.sublimetext.com/3 If you want a free IDE that is almost exactly the same take a look at Atom atom.io/ Yes you can use your command line just like I use the terminal. Everything works pretty much the same. I hope that helps :)
+Derek Banas Do you know a way of downloading the latest version because my pc doesn't seem able to open tar.gz files? Thanks for recommending Atom :) Is the terminal the same thing as the command line? It's just I don't quite understand it. How do I get Sublime Text to interact with the terminal?
+Oliver Benson You can use the install program on Windows for Atom and Sublime text. You don't need the tar file. I just recompile in the terminal. You can run the terminal in both IDEs, but I have never done that.
Note: An error in the video says modulo operations cut off decimals, however *they do not*. He mistakenly typed 5%3 instead of 5.2%3 in the math area.
You go a little to fast but you explain very well :)
Thank you :) Sorry about the speed
go to setting and lower the speed. thats what i do when doing practice at same time.
haha, then he sounds like drunk!
Excellent outline of Lua and I would be interested also in functional programming with Lua.
Thanks, I didn't know a thing about Lua, but it's quite simple. Not a complicated language at all.
That said, I wished you had picked better examples. For instance the first table at 25:30 is confusing to me because you kept using index 1. What is confusing is that we don't know if there is an element zero at all, and if so why it's not reported in the length calculation. A bit more explanations of what actually happens to index zero would have been very useful. As it turns out there is an element zero and it contains nil (I've checked).
And the other issue is at 31:30 when you return the wrong number of words (one too many), but when you get an extra "nil" you then explain it by saying that tables are always nil-terminated, which isn't true at all (I've checked too).
Barring those two confusing points (well the second is real easy to spot to someone with programming experience), the pace is good and the content is really practical. Thanks again.
No, there is no element 0. All tables in Lua start with an index of 1. The only reason you are getting nil is simply because it doesn't exist. And, also, all tables really should be nil-terminated. If your result showed that to be false, then please explain what you did to test it because I would love to know how that could be possible.
omg! first of all thank you! most videos just throwed me to the os x website and I did complete a mess because I did not understood what was wrong. It's really important to mention as much system as possible so the viewers could actually understand and follow and understand. Thank you so much!
You're very welcome :) I'm glad I could help
That's just perfect. Thank you :-)
+Stéphane JAILLIARD Thank you very much :)
If you care, you can slap a 00:00 timestamp in the description to set chapters up to make the video more easily navigable
vid was 8yrs ago chill
@@densket_ they appear to still be active, and it’s basically already set up
Here let me fix that title for you...
Lua tutorial for people with an extensive background in programming.
There! You're welcome...
Well, it's kind of dumb if anyone expects that a >1 hour tutorial will cover basic programming fundamentals. All of Derek's crash courses focus on syntax, not basic programming fundamentals
@@garybrock8456 Sooooo, i want to learn Lua from zero. I only know some Pascal and no more, what should i do?
@@yegorgribenuke6853 Look at a different tutorial mate. These tutorials are aimed for programmers meaning you should know how to program as in basics fundamentals of programming. These crash courses are literally him teaching you the syntax of a language I come from C++ so all of this is really easy to understand. I don't want to watch a Lua tutorial that explains to me what functions, loops, selections and so on are I already know what they are. Am here to learn the syntax of this scripting language.
@@설리-o2w they teached us Pascal as programming language for us understand others.
I understand how it works, i do not know any commands and any functions, thats my problem!
@@yegorgribenuke6853 well watch the video then. That's the whole point of learning this language syntax :D.
I can only imagine how frustrating it would be to not have any programming experience and watch this video, lol. I love that you did it for an audience of people with experience, as I do not have to waste an extra 5 or so hours on some slowpoke course lol.
Thanks :) Yes I tend to make videos for people that already know the basics of programming. I hate wasting time
ikr i was so happy to find this course that under 1 hour and goes rapidly through subjects that are for example included in python
Lmao I was expecting a "Explain it to me like I'm Five" kind of tutorial, still helpful since I briefly do Python and Java Script in Highschool and tried Roblox lua on my own before actual lua. So "some experience" lol
@@derekbanas I know zero code, I'm 14 years old, have never coded past scratch junior no matter how my parents encouraged me from ages 6-10. To say I am lost watching this video is an understatement 💀
Just wondering, are there annyone else than me that is watching this for help to script farming sim? :P
Well I mean
What
Good video. Lua quirks: arrays & strings index from 1, not 0.
Your ternary example with booleans is misleading "foo = (condition) and true or false" as that is identical to "foo = condition"
Better example, showing wierd Lua quirk, would be:
age = 13
foo = (age
Hey :D
Do you know if that covers the "MTA Lua" ?? Its a bit different from original Lua
Correction: around 7:20, the claim was made that the modulus operator "automatically cuts off" decimals, but the actual code being ran did not include a decimal -- only the string portion describing the operation had the decimal. As of Lua 5.1, executing `5.2 % 3` will give the result 2.2, not just the integer portion.
I want to mod a server in mta sa... but god my head hurts
My brain melted at wtf you were doing with splitstring
Derek Banas
First off; very nice video; as always. I really enjoy your stuff and I think it's all really awesome.
One small thing with a big impact I had to point out though:
In the 'OO' section of this video; you're constructors are wrong in a very subtle way.
The way you wrote it; your X:new()'s are simply modifying the existing table and returning it.
You can check this by simply making two Animal `objects` and comparing them with ==; same goes for two Cat `objects`.
I've written the necessary changes together with a few explanations here:
paste.ubuntu.com/11793664/
Again, I very much love your videos, and very subtle mistakes like these are perfectly natural. Pitching in a little hand is the very least I could do.
Thanks again for all the great content; you rock!
Nashwan.
Nashwan Azhari Thank you very much for fixing that :)
The reason that 9223372036854775807 is the largest number you can hold is because this number is the 64 bit integer limit. 64 bit programs simply cannot hold more data than that. The only way to display a higher number than this is by using a string and not an integer
I tried while loops, Roblox crashed (yes, I am learning with Roblox)
qCmdUtl Rōblox (Windows 10) Yea, I figured it our a while ago. Thanks for the help, though.
Roblox uses rbx lua so some stuff will be different
This is crazy. I searched for 9.2 quintillion and the first result was that the odds of successfully choosing a perfect NCAA March Madness bracket are 1 in 9,223,372,036,854,775,808. exactly one digit higher than the highest number you can go in Lua. Turns out that number is an even composite number. It is composed of a single prime number (in this case two) multiplied by itself sixty-two times.
If you are here from Roblox, don't watch this video. Some things are useful, but Roblox uses a modified version of Lua with more functions.
i want to learn lua anyways, and nobody does a good tutorial rather than this guy
Well, if you have NO knowledge of programming, learning Lua is still going to be helpful in terms of some syntax and things. And on the plus side, knowing any programming language makes it easier to transition to a new one, Lua or not.
@@neurofiedyamato8763 As a Roblox Developer, the syntax on roblox is so watered down that they just use a base of LUA and add their own functions entirely.
@@TeddyHartling Hey what do u recommend to learn lua in Roblox?
oh k
Just started coding about 3 months ago. This video is way to fast for me to understand anything. I believe this is for people who have coded in other languages before Corona. I will come back and listen again when I have more understanding.
Yes this tutorial is meant for someone that has already mastered 1 other language. Sorry it didn't help
**=** Basic Lua codes can work on Roblox Studio?
yes. Roblox is ran off of Lua and basic Lua codes.
@@kierstyn3330 **=** Yes, but not all codes, and Roblox use Ogre3D engine.
Straight forward,no bs,just lua,excellent!
Thank you very much :)
"aight imma learn to script for a school project"
*2 hours later*
what the fuk is this?
he explained everything so fast!
THAT'S WHAT I WANT THANK YOU!!
im skipping maths lol
Lua gang! I'm excited to get into something new, thanks for the opportunity.
Legit Roblox's tutorial teaches you 'Hello World' in their tutorial and in Studio.
eww roblox player
@@fire-fx2ct why
Hello world is the most common text in tutorials. Of course you'd fins it there too
Lua is a language that roblox just happens to use. He is teaching normal lua for real programmers.
I started Lua for conky, stayed because it's awesome. Thanks Derek!
I'm happy the video helped :)
Why are you using io.write, why not just print lol.
L0gicz
The difference is that io.write adds text to the most recently used line while print creates a new line
Example:
for I=1,4 do
io.write(“cool”)
End
Terminal:
coolcoolcoolcool
Example:
For I=1,4 do
Print(“cool”)
End
Terminal:
Cool
Cool
Cool
Cool
@@PixelBytesPixelArtist but you can also do print("coolcool") so yeah
Well it's good for making text matrixies if you arnt using a 2d engine.
example:
for r=1,5 do
print("")
for i=1,5 do
io.write(" 0 ")
end
end
terminal:
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
--If you used varibles instead of text you could set each point to something other than " 0 "
@@hydropage2855
Sorry, i dont know the difference, i dont use the system library much.
This is the greatest example of *looks at tutorial* *looks Away* *tutorial is awesome*
16:04 that seems a bit redundant, can't you just say:
canvote = age > 18
Not if you want to return a different value that's not an boolean
Yeah, strings probably would fit more naturally to illustrate ternary operator, but my concern is that lua version of it is pretty weird in itself.
@@michielarkema that's kind of my point. ternary operator is better illustrated with non-boolean types
Ok, now you've officially beat Darth Vader as the most inspirational person on youtube! Thanks for your dedication, and if you had time unity3d.. been developing a game on android thanks to your tutorials, then decided to switch to unity, and for 2 weeks been digging in da' documentation...suuucks. Keep them coming, and Lynda should hire you!
dilo00o That's funny :) Thank you I'll see what I can do about covering Unity
Time to hack some mobile games
Zetta_Stone I was gonna code some gmod but ok
Amazing how much I was able to absorb watching this at 1.5x! Great video :)
Thank you very much :) I'm happy I could help
What on earth is Lua??? Oh well, we'll learn it anyway ;p
Phil:) That's funny :) Here are some projects that use Lua sites.google.com/site/marbux/home/where-lua-is-used
Phil:) It's used a lot for mods like skyrim, elderscrolls online, Rust,...
Derek Banas:So its mostly used for things related games, simulators , etc isn't it ? But one thing that surprised me is its use in robotics,so I got one reason there to learn it.Thanks for uploading.
Derek Banas Thank You!
Lol
This seems to be really simple so far! This is coming from someone who barely remembers python and is much more used to block coding in engines, but I'm looking into Lua for a certain engine.