Programming in Lua (PiL) - Introduction to Lua from lua.org

development
scripting
lua
programming

#1

https://www.lua.org/pil/contents.html


For a bit of time I’ve been thinking over this. There’s been many threads on the DevForum asking where a good place to begin exploring Lua would be or where they can find documentation to help them along their learning path. There have been mentions to the Roblox Wiki, video tutorials and obscure mentions to PiL - but there wasn’t actually any dedicated thread to PiL. That’s when I thought to make this thread to share PiL so that it’s accessible to you without needing to search too deeply or come across it by chance. Just open the Resources category and wham, here it is.

The link I posted directs you to the online version of “Programming in Lua” on the official Lua website. Though it is mainly aimed towards Lua 5.0, it still holds major relevance and has the necessary know-how for you to program on Roblox. The code you write in Roblox Studio is a sandboxed version of Lua dubbed “RbxLua”. Most of what Lua has to offer is available in Studio, as well as Roblox-specific implementations. Any number of resources out there can help you all the same, but if you’re starting from zero, this may just be the hand you seek.

If you are looking to learn Lua but are unsure of where to begin, this would be a good place to flip through. It covers the basics and works it’s way down to advanced practices. Depending on your ability to comprehend the material it may take a few re-reads or questions before you understand, but at the very least you will be able to understand some things about Lua and perhaps start on basic programming.

This is not to say that you shouldn’t also read the Developer Hub’s articles or anything on Roblox’s Medium page. Both of those respective resources have amazing articles on specific subjects and also help towards such learning. PiL can help you to understand Lua concepts and tease you into exploring the awesome world of code.


#2

Most people that want to learn how to program in Lua just want to script in their game, showing this link is going to bore or scare them from scripting.

The best place to learn is either Youtube with some videos or the Roblox wiki.

Or both.

https://developer.roblox.com/videos/Intro-to-Scripting-First-Script


#3

Yea honestly I completely agree
Wiki is just so bad nowadays


#4

Any kind of reading or non-interactive tutorial will “bore” someone. If you aren’t willing to put in the effort to learn, then you shouldn’t bother with attempting it at all. Everything comes with both the learning and the practice. In any medium you present a person that wants to learn, they still have to sit through it.

Programming in Lua is a basic and advanced introduction into coding with Lua and understanding the concepts necessary to begin using it, with all its sections explicitly divided to cover certain topics and go over them in such a way that is easily understood.

I would not ever recommend directing anyone to a YouTube video or the Roblox Wiki to learn code. Those are subjectively the two worst places to begin. Every YouTube tutorial on Roblox Programming is different on where they begin and what they define as what you should start with, whereas PiL anchors where you’re supposed to start - getting familiar with how things work first before jumping into coding.

Videos often jump straight into practice and assume that you know how things work at a very basic level. They are more interactive than reading but they don’t have the sufficient amount of knowledge one would wish to seek if they’re starting from absolute scratch.

I shouldn’t really have to explain why starting at the Roblox Wiki is a bad place. For expanding your knowledge or comparing what you learned, sure, but it’s still good to first learn the basics to the language Roblox games use first before jumping straight to practice.


#5

It’s easy to make a lot of assumptions about what’s the best way to learn but in everyone learns a little differently.

I first learned how to program (with Lua on Roblox back in 2009) mainly by example and by reading the manual. I tend to learn best by getting a high level conceptual understanding and then drilling into API references or manuals. I found PiL frustrating and mostly ignored it.

An important thing to keep in mind about PiL is that it was written against Lua 5.0, which was released 15 years ago. There’s many places throughout the book where what it teaches doesn’t carry over to Lua 5.1, and it’s really frustrating when code you based on the book doesn’t work. It also suggests you use some fairly idiosyncratic patterns, like error"insufficient funds", which most developers don’t use.


#6

EDIT: Confused objectively with subjectively, edited posts.

That’s why I said subjectively. It’s not necessarily that I am saying that everyone else’s form of learning is wrong, no. Everyone has a different acceptable medium for what they’d like to learn first. It’s my own personal view that starting from either resource is not the best plan, but I didn’t say outright that it’s not good and that everyone should switch just because I said so.

It goes the same way with me as well. I learned to program with Lua in around 2011 by picking apart open source places, primarily ones by Rudimentality and experimenting around with things until I got them to work. I’m a more practical learner and prefer to use articles to help build upon that knowledge if I’m able to comprehend what the material is showing me. Perhaps not all of PiL may be suitable for everyone, but the first few articles have quite a bit of information that you can use to get started on understanding Lua.

No argument against the bottom. Although a good portion of PiL is still quite relevant, it’s not necessarily up to date. I get that. That’s a flag to branch out to other resources and continue your learning from there.


#7

The main problem that I have with PiL as a new learner’s resource is that it seems to be aimed at people who already understand certain vagaries about programming languages in general. For instance, in the first chapter of PiL there’s a (very brief) discussion about semicolons at the end of statements, which is most likely just going to be extremely confusing and useless if the reader doesn’t already understand how or why semicolons are used in other languages. The entire book is littered with little things like this, which is fine if you already “get” them, but borderline nightmarish if you don’t.


#8

I’ll try editing the post in such a way that accommodates this point-out (as well as any input posted above). Thanks for bringing it to my attention.