Any advice for a wanna be coder?

Hello Gentlemen

I want to start learning lua and coding addons etc.

Any advice? Places to learn from, where to start that sort of thing :slight_smile:

Try to figure things (problems) out on your own. If I had done that when I started programming instead of asking programming aficionados I would have learned a lot quicker.

Get into good habits. Comment things, keep them organized, if you come across a problem as rbreslow said, work through it. Only ask if you are absolutely stumped.

Yes but I mean I am starting almost from scratch! The limits of what I know is editing config files for scripts I bought on Coderhire haha! Any good sites to learn from?

You need anything, look there.

Take workshop addons apart that do something what you want it to do, and see how they do it. Then create your own method.

Yeah write your code so other people can easily follow it. Good variable names, well documented functions that describes what the function does, acceptable input, and expected output. Basically all the good programming practice you learn in an entry level computer science class. Also being an efficient typist can help prevent annoying syntax errors.

http://i.gyazo.com/922dddbd2ae95ea9e40e0de4264981bb.png

That’s really good advice :slight_smile: Thank you for your help. If anyone else has other useful stuff I’m all ears :slight_smile:

[editline]15th May 2014[/editline]

Nookyava I’ll start right now :slight_smile:

code_gs gives us tons of resources for that

My way of learning is more hands on. I edit weapon and addons as well as read tuts on the wiki. I’ve only been learning it about 6 months :v:

You can read through others code and try to see how things work (I can read lua but have a hard time coding in it) but you could do better than that. Good luck!

Edit: don’t expect to get it all at once

You’ve been blessed by the Lua fairy. ( This video will be tough but probably inspirational. )

Anyway, if you want to start coding the fun stuff you need to learn the absolute basics.



local a = "Hello"
print(a)


The way I started out was by learning from a helpful friend. He didn’t spoon feed me, but he did help me understand things. If you want you can PM me on this forum about any Lua questions.

I’d say the first step is learning the Lua syntax:

**or **this link: http://www.lua.org/manual/5.1/manual.html

I’m still learning, and still a lua noob. Honestly, there is a huge lack of information on the current garrysmod wiki. It’s my main source of gmod-specific lua commands, but often it doesn’t give enough information, like for example how to code a basic STool. Luckily it’s easy to just open them up in notepad++ to learn from them, but the downside to that is that when you’re a complete beginner you often need certain things explained.
(My first project is btw to re-create the old keep upright tool… with perhaps a few additions :>)

Don’t give up forever just because you can’t do everything straight away or struggle at first!

As others have said, these are excellent : http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7a06.html

Once you know the basics, try and choose a very simple project and then build on it as you learn. My first one was a permanent weapons add-on which allowed admins to use commands to assign weapons to players that they would always spawn with. It wasn’t very efficient (eg. each player had their own file which listed the weapons) but it worked, which is all you want at the start.

Another thing I’d suggest which has always helped me is to not be afraid of going back and editing what you’ve already done to improve or make more efficient. Currently I’m coding a game-mode and I’m constantly going back and changing how things are done to improve them.

If you’re just starting, feel free to add me on Steam. I’m not great as I’ve just started as well, but I can definitely pass on some advice as you go that would have saved me time.

In summary, learn the basics, choose a small project that has a purpose, try out as much as you want in this project to learn how things work even if it’s not really needed, go back and change things as you learn how to code more efficiently.

Don’t join a community, you may feel the urge, don’t. For the love of god don’t.

Ye I’ll have to agree with this lol

You know, you could just press the agree, which you did. Not needed to reply saying you agree.

The wiki is your best friend.

Make sure you are programming in an environment that has syntax highlighting, or you will go insane.

Don’t make ridiculously long functions. If it can be split, divide it up into several smaller ones. Your bugs will be easier to track down, your code becomes prettier and more manageable/maintainable.

Don’t make useless comments:
[lua]
– Loop through stuff here
for i = 1, 10 do

end
[/lua]
Comments should mostly explain why you do something, not what you are doing.

[editline]16th May 2014[/editline]

Also, the less code; the better. Code length is proportional to code complexity, and complexity means bugs.

It’s important to note that a lot of things on the old wiki are outdated, and changed between gmod12 and gmod13. I made the mistake of looking up some lua funcitons there, and then wondered why I was getting code errors… So be careful using the old wiki.

Yes, very good point to add. The beginner tutorials, I believe, are still relevant? If I’m wrong please correct me :slight_smile: