Learning Lua and GLua

So you want to code for Garry’s Mod, but have no idea where to start. Assuming you have no knowledge of any kind of programming language, Lua is a good place to start because it is a high-level scripting language. Other good programming languages to start with include Java, C# (easier than C++), and Python. Before you start with any programming language, a useful program to have is Notepad++, or Sublime with Falco’s highlighting for GLua. Word and Wordpad will NOT work. Notepad will work, however, it’s recommended to either use Notepad++ or Sublime for the organization and highlighting.

GLua is a modified version of Lua, so you may find it beneficial to learn vanilla Lua first. Here are some great resources for that:

If you already know Lua, or you would rather go straight into GLua (it’s highly recommended you start with some basic Lua first), here are many useful resources:

If you are converting old code from past versions of GMod, these are very useful:

If you are a more hands-on person that likes seeing examples, here are some YouTubers that do great tutorials (thanks sm69baller):

If you want to try Lua in other environments besides Garry’s Mod, both World of Warcraft and Roblox utilize Lua in very modular ways. Here’s a full list of games that utilize Lua.

Good luck on your learning experience! If you have any suggestions, post them and I’ll add them.

Awesome stuff. In another thread, you mentioned you had some more information besides the ‘why your scripts are now broken’. Did you find this in the end?

Yes, it was the GMod13 File library changes.

Ahh, okay. If you weren’t aware, you need to request access to see it.

Fixed it.

add something about using wordpad or word. using one of those programs to code will not work, and i have seen too many people try to.

Most of the people who have added me and asked how to get into lua also asked how to upload stuff to the workshop, so that might be nice to add to the OP.

There’s also a Wikipedia page which lists a lot of games that use lua. Some of the other notable examples being Natural Selection 2, Crysis, Civ 5 and Just Cause 2 Multiplayer.

I’ll make a tutorial later on how to upload stuff to the workshop (unless someone else already has).

Couldn’t you just link to the thread garry made about how to do it, maybe adding a bit more emphasis on the fact that people have to compile a gma first?


also add sublime text as a possible coding program since i use it and find it to be better than notepad++, ftpje released an up to date glua syntax plugin for it located here: https://github.com/FPtje/Sublime-GLua-Highlight

Lol no problem ; DD


Great post! I should preface this question by saying that I have no knowledge regarding Lua and GLua. So what are the main differences between the two? And why would one want to skip directly to GLua?

What about sublime text?


This looks familiar, lol. Nice work man, this is helpful!

Added functions, libraries, etc. You can’t really “skip” Lua for GLua since it’s still Lua, but one might want to jump straight into GLua if they only plan to use Lua for GMod. I still highly recommend you start with basic Lua first to at least have a preface to what it’s about.

This is what I post each time the question arises about learning Lua:

Here are some resources which may help you:

The Lua manual, this will definitely help you get started!

Learn optimization techniques right away to avoid bad habits:
http://www.lua.org/gems/sample.pdf [PAGE 4 – But read the entire thing]

The New Garry’s Mod Wiki, has a ton of information, how to use the function calls, how to integrate vgui elements, and more!

Not everything is on the new Garry’s Mod Wiki yet, if it’s not there, it’s here. There is a lot of things that has changed since Garry’s Mod 12, to Garry’s Mod 13. This is primarily for 12.

One of the best places to start, if by modifying TTT. Start by changing the sweps, more realistic fire-rates, balance the damage, add a feature which changes the cone based on if you’re moving, firing from the hip, aiming down the sights, crouching, holding the walk button, etc etc. Start small, start by doing simple things and work your way up!

Sublime looks really cool, so I think I might swap over to that, especially if the syntax highlighting is up to date.

I really wish there was more physical books about lua, I know there’s one or two but if I recall they’re quite expensive too. I know it’s probably a small market, but I’d love something I could read in college.

PIL (programming in lua) isn’t too expensive.