Learning LUA - Where to go to after the wiki?

Hello, I’m trying to learn GMod LUA right now, So far I’ve read the Beginner Tutorial Intro followed by the tutorial on making the chair throwing gun and succeeded. I understood the code of the gun well but I feel my LUA knowledge is still too limited at this point to do anything useful. I can’t find anything to read next in the wiki that fits my skill level so my question is: Where do I go from here? I would really like to become good at coding addons in GMod for my entertainment and the entertainment of others.

TL:DR Where do I go after reading the beginner intro and chair throwing gun tuts on the wiki?

Try converting old broken addons from garrysmod.org

also, it’s Lua (loo-ah), not LUA.


I prefer to type it LUA because I think it looks better that way, I guess it’s a personal thing though.

I don’t think I actually would be able to convert old addons, As I don’t even know the differences that make GM12 addons often incompatible with GM13, and it seems like a complex task. Keep in mind that I am a sort of inbetween beginner and intermediate.

I guess I might be able to pull it off if I find a simple addon to get me started. I’ll look into it.

Thanks, I’ll look at that. More help would still be appreciated though. :stuck_out_tongue:

EDIT: Wahey! I fixed an addon! I think it had already been done but I was able to fix it manually nevertheless. Said fixed addon was the Halo weapons pack (picked at random)
Fixes include:
–Made the rocket launcher spawnable
–Stopped shotty reload animation from getting stuck
–Fixed an error with an include
–Made the rockets from the launcher face the right way.
–Probably other stuff I can’t remember!

I want to try another one now.

Fixing broken code, provided it’s complete, isn’t overly hard.

You look at whatever error is produced in the game (or server) console, find the referenced line in the .lua files and then lookup the function (google, or wiki.garrysmod.com) and find out how it should work.

For example, a “table expected, got nil” error is pretty self explanatory. You find the variable that should be a table and track it back to find out why it’s not being set

There isn’t really anywhere else you can go to ‘learn lua’, you need to think of a script you want to make (start simple), do some research on the wiki to get a basic knowledge of the functions and libraries available for use in your code and then just start building it. You’ll write a few lines of code, test it, figure out why it doesn’t work and then fix it, then move on to the next few lines. Just remember to be patient, make your code neat and logical so you can find errors easily and google google google!!

Thanks, Will note.

That’s sort of the same thing I did with the halo sweps combined with knowledge I have learned in the past from things like the chair gun. :slight_smile:

Fixing old addons is actually pretty easy. I thought it would involve tons of work but it mostly consisted of making minor fixes to single lines of code. (for example, alot of the halo swep errors came from timers that needed updating.)

LUA doesn’t look better, LUA is an acronym. Lua does not stand for anything, it is a word. You look stupid calling it LUA, don’t do it or you’ll be forever shunned around here.

“Lua” (pronounced LOO-ah) means “Moon” in Portuguese. As such, it is neither an acronym nor an abbreviation, but a noun. More specifically, “Lua” is a name, the name of the Earth’s moon and the name of the language. Like most names, it should be written in lower case with an initial capital, that is, “Lua”. Please do not write it as “LUA”, which is both ugly and confusing, because then it becomes an acronym with different meanings for different people. So, please, write “Lua” right!


Lua Used as an Acronym

Where to go after the Wiki… The old wiki



This might help you.

Feel free to add me on Steam: http://steamcommunity.com/id/Acecool

I’m working on creating tutorials and quizzes non-stop. Additionally I tutor people on a daily basis.

code_gs I haven’t forgotten about you, I’m still rearranging my tutoring section. Also, this new thing I’m doing is quizzes, basically given a task to do such as update x, y or z to do something else, or the same thing but more efficient, etc…

Answers will be the same tutorial filename_answers.lua

The first one I’m doing is for the end-round-music that I give out, basically convert it to have a shared file whereby the sounds are declared there, and have the net-message send the win-type and the index of the chosen music instead of the string, simple / straight-forward but given time, building up a bunch of these would probably help a lot of people out.

You don’t actually go anywhere after wiki, wiki is your primary source of function and hook definitions, you’ll HAVE to visit it every now and then to look something up. But yeah, the old wiki has way more tutorials then the new one does, so you can try looking there.

I’m pretty sure Garry wanted to get some tutorials up on the new Wiki. Robot, is there an area for tuts? If so I could add a few ( my coding style for my examples, of course ). :slight_smile:

And here they are:

Pls no.

_Dear _god _no _!

I’m going to be setting up a website called:-


Its going to be an archive of everything I’ve coded, with instructions on how to use this, and how its worked. It will be up soon (If I get funds to host it).

It’s not too bad, I’m even writing up a coding-standards document - will port it to a Google Doc later with better formatting:

Template for DropBox tutorial quizzes, will also have a Google Docs template

Coding Standards partial write-up.

Documentation example:
Besides, the meta-table objects use the same coding standard, and are really clean: https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/acecool_simplex_networking_system.lua

Underscores are for local var, or double for vars that contain data within a structure…

Don’t worry, I’ll make sure they understand that the underscores aren’t required with each tutorial… Maybe I’ll do them your way and post a link to the drop-box with my standards.

[editline]27th March 2014[/editline]

If you have control of the domain, update the name-servers / or just redirect the side to a sites.google.com. You can host something there for free; I’m not sure if you get a database though…

@OP - the best way to learn something is to just go for it
make a few things, post in waywo and get feedback

i don’t want to start this argument again, but the reason people react badly to your coding standards is because it’s just so different to normal lua. the thing that makes lua an easy language for beginners to learn (the people tutorials will be aimed at) is the clear syntax and easy to understand operators and such.

so instead of
[LUA]if not data[ply:GetData()] or ( ply.var and ply.var ~= “1” ) then return end[/LUA]
you do something like
[LUA]if !__data[_p:GetData()] || ( _p._var && _p._var != “1” ) then return; end[/LUA]

what I’m trying to say is that it’s great that you have your standards you follow consistently, it’s just that they’re a fair bit different to the norm, and it’s not really something beginners should have to worry about.
I know when I started I had no idea why people were using underscores and || operators and stuff, same with semicolons

So essentially keep it simple for learners. Give them the basics and let them develop their own tastes, don’t shove your _hardon for underscores down their throats.

not trying to flame, just my opinion

I completely get where you’re coming from. I did write in that maybe I’d write it “normal” except I wouldn’t use and/or/~ but everything else would be “normal”.

Also I’d be pretty close to the original on that, depending where data comes from ( if it’s locally defined, or called elsewhere depends on if it gets 1 underscore. If it’s part of a class which holds data like the language system, then it’s 2 – for _p.var, I’d use no underscore for that. I only use __ in a table / meta-table when it’s to hold data that shouldn’t normally be accessed )

Example Here’s the re-defined language meta-table / class. I rewrote it because the original was C based, and on top of that it doesn’t support multi-languages in game-modes which is one of the reasons why TTT wrote their own from the ground up. This basically keeps all original syntax while allowing “dictionaries”. I suggested to have this added into gmod to replace the C version, but Robot didn’t like the idea…

Default Language is “en” for English, so if you’re using a default language you don’t need to define anything and could just add stuff in. During my tests, I actually have addons which populate data into it properly.

And here’s a slightly newer version: https://dl.dropboxusercontent.com/u/26074909/tutoring/classes/class_language_new.lua which fixed an error if GetPhrase was called before Add, and added additional options for GetPhrase to allow string.Format to automatically be called within, etc. I’m going to extend it to allow automated usage of the build-in functions for plural, a/an, 1st, 2nd, etc based on certain replacers.

As you see, I use __ for the meta-table just like the built in __index is there, __type is for extended typing, and __default is for a default language in addition to the __dictionaries. They’re initialized within for auto-refresh compatibility. I don’t see it as too un-readable but I’ll make sure when I post a tut it’s more friendly.