Lua - Probably One Of the ONLY Tutorials for Lua Out there..
So, I've haven't really seen much Lua tutorials out there, so I thought I'd try making my own (based on what I know!)..So, here ya go! The
(really dumb) LUA TUTORIAL!!!
Yeah, AMAZING isn't it? Okay, so let's go from the very start. Print functions. You know them by now right?
Simple as pie, isn't it? Well that's the print command, a built-in function that prints a String (or str if you're fancy) into the console!
So why Lua?
Well, I get that there may be much better programming languages out there, but believe me when I say that lua has helped me understand python, etc so much better! And again, I'll teach you Lua and why it's good for me (and maybe for you ;])
But what if we could do it another way? Perhaps a..
Yes, I'm not joking you can use functions on this bad boy too, and in my opinion, easier to learn than python (can differ from your first language). So..
What's a function?
A function is an essential to most scripts/code made on replit, you probably saw python code with like idk, let's say
Yeah, that makes no sense to me at the moment, but I can tell you now, lua functions are as easy as 1-2-3! Let's make a function right now..But what?
Coming up with ideas
It's not a surprise that you need creativity to think of something good, BUT! The best coders were never the brightest at the start. They've most likely taken code from the internet and observed it, tinkered with it, sees what goes wrong if you change something specific in the code. It's all a part of the learning process!
So, finally, let's get started with the functions!
Now, let me explain the END part. It's to end a function, because you don't want the code thinking the whole of your script is the function, now do ya? :]
Basically, we call the function's name, which makes it run. Pretty simple..Isn't it? Well, now that you should know functions, let's do a for loop!
Okay, let's just do a simple for script:
Now, I know this looks complicated, but let's think for a moment. For every i (which is 1), until the limit (which is five) do (code here). I'm adding it until it hits the limit, then it'll stop. This is the expected output:
Not much to add here, just adding! We'll get back to this another time...And, that's part 1 for this tutorial! I know it's short, but you got to keep in mind I'm also still learning, this isn't all that I know by the way, but I want to do it step by step so nobody is confused.
Well, you can always try the examples when you first start a replit with lua, it might not be as helpful, but like I said the best coders learn from pre-made scripts. Also, if you ever find code hard to make, and you want to maybe find help on some website like for instance "stackoverflow", then please keep in mind of this quote!:
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”
― Martin Fowler
Now, with that in mind, I hope you enjoyed this tutorial, first post I've ever made (don't get mad at me if I didn't markdown correctly, I'm new to this ;w;)