How did you learn Lua?

So, I’ve been coding in Lua for a while now, covered all the tutorials on the GMod wiki and it feels like the only way I can increase my knowledge is by reading the entirety of PiL… but that’s just not fun.

So my question is to those of you who see yourself as knowing a lot about Lua or just to those who have a nice portfolio of Lua or game design in general, or even those of you who are modest and would just like to give some advice;

How did you learn Lua? and what would you recommend people do, read, watch or investigate to learn more?

P.S I avoided posting this in the questions section as I’m not necessarily asking for help with Lua, I’m just trying to get a discussion going.

Well, the thing that got me to coding was some perfect dark weapons pack addon on
Was so proud changing the fire sound name in the shared.lua file to some other guns fire sound.

That was my first ever experience with Lua or coding/programming in general. After that, not even realizing that there are tutorials or even a forum called facepunch tried to combine various pieces of code from elses work, finding out how everything ticks. Until I’ve gained enough knowledge so that looking at other people’s work for code became inconvenient and just started trying to write my own code instead.

For beginners I’d recommend going through the tutorials first then checking some tiny addons, like weapon packs or some entities to learn what does what.

Just wanted to make something.

Begging, reading, and trying.

Learned how the syntax and the language itself worked thanks to PIL, then I started reading others’s code and used the GMod wiki as reference to write my own stuff.

Mostly reading.

This. It’s probably the fastest way to learn. What noobs fail to realize is until you understand how the language works on the inside, you will fail to learn how to write your own code without looking at others works. Programming requires a unique way of thinking to efficiently get your work done.

Download luapad from, and like this, you will learn WAY more than you expect:

[lua]for k, v in pairs(ents.GetAll()) do – This scans every entity
if v:IsNPC() then – If its an NPC then
v:SetColor(math.random(255), math.random(255), math.random(255), 255) – Give it a random color
v:SetMaterial(“models/shiny”) – Make it a solid color
elseif v:GetClass() == “prop_physics” then – If its not an NPC, and IS a prop then
v:Ignite(25) – Light it on fire
local random = math.random(500) – Generate a random number
v:GetPhysicsObject():SetVelocity(Vector(0,0,500+random)) – Shoot it up into the air
end – Finish the sorting
end – Finish the scan[/lua]

Find more things to “v” which is the entity found, here:

I wanted to piss some kid off. Wrote a script to spam a Derma menu going to MeatSpin 2Girls1Cup etc.

No Close Buttons…

(math.Random() ) For Da Win!

In high school I learned Ada.
Soon after finished Programming A and Programming B I discovered Garrys Mod.
Found it fascinating that you could make your own weapons so I couldn’t resist to have a look at it
since I’ve only used the command prompt when programming Ada.
So I just started by reading other peoples code and getting used to the syntax.
Also started by checking some beginner tutorials and after that I just kept going.

You should find it fun to do scripting or programming on your free-time (as a hobby).
If you find it fun then learning and improving won’t be a problem.
If this isn’t obvious then maybe programming or scripting isn’t for you.

Believe it or not but there is quite a big difference between programmers who have just
learned programming and people who actually find it fun.

Wanted to make TPC (Tactical Police something or other) in Garry’s Mod 9 give cash for killing NPCs.

Set out reading the wiki and fucking with shit until I got it working.

DarkRP editing :downs:

i started of by simply taking someone elses weapon and made it shoot faster.
then it kinda picked up from there.

about same as the guy above but i dont really know i just hope for the best

I became really good at expression 2, then realized I should try Lua. After reading everything all tutorials and the documentation part on the Wiki I sorta said “now what” so I made a poor gamemode. Ever since I do small things for friends. I love it too, I always do the stuff for free (it’s fun, not a job).

After learning E1, I wanted to try to learn a programming language but wasn’t sure which. Then E2 came out which was the perfect excuse.
After that, I found out that gmod uses lua and read up on pil and the glua wiki.

Back around 2005 or 2006, I took a VB class and learned the basics of programming, and applied that to Lua. I spent that summer more or less teaching myself after looking at a few example scripts on the old wiki and some sweps, and reading theJ89’s tutorial a couple of times.

I really learned to love short load times over the years.

Slowly dissecting scripts and Frankensteining my own together.

It works…eventually.

Lua PIL, pretty much the holy bible imo.

I started out modding TTT SWEPs, and slowly moved on to more complex things, now i’m making my own gamemode.

Lua wiki helped quite a bit with learning gmod functions etc, although some of the tutorials are pretty crap to be honest and I probably learnt more about the syntax of the language from looking at other’s code and making my own.