Author Topic: Learning to code for Gmod  (Read 5772 times)

Offline rBST Cow

  • Tinniest title on CG
  • Gold Member
  • *
  • Posts: 2,178
  • Awards [OCRP Award] Dedicated Player [OCRP Award] Millionaire [OCRP Award] Secret Phrase [OCRP Award] Evo City Half Marathon
    • View Profile
    • Awards
Learning to code for Gmod
« on: May 31, 2014, 03:23:14 PM »
I know really basic Python and basic HTML but aside from that, I don't know much about coding. I'd like to learn about how to code for GarrysMod LUA but I'm not sure where to start or what resources I should go to in order to learn. Perhaps once I get a grip on it I could help code for CG?

tldr:

I'd like to learn how to code for Gmod, what websites/resources will allow a newbie like me to learn?
abbot common stop bad for you if u watch anime all day nigga u fuckn weaboo

Offline Nicknero

  • Hatsune Miku
  • Gold Member
  • *
  • Posts: 5,032
  • Awards [OCRP Award] Millionaire [OCRP Award] Evo City Marathon [OCRP Award] Social Player [GMR2 Award] 100 MPH
    • View Profile
    • Awards
Re: Learning to code for Gmod
« Reply #1 on: May 31, 2014, 04:06:26 PM »
http://wiki.garrysmod.com/page/Main_Page

On the left side, expand those things and you will find all kinds of things used in LUA. click on one of them to find out what it does and sometimes even gives you an example.

The best way to start with any code language is to first understand the basic layout on how things are written down. In this case, the whole
function BlahBlah(blahblah)
....
end)

idea.

Then grab an example project (DarkRP for example) and start reading that code. Get to figure out where everything is located and what the difference is between client (cl_init.lua),  server (init.lua) or shared (shared.lua).
Then start to edit the code by adding your own things, or editing existing things. Then see what happens in-game.
That's how I usually learn new script languages.
Check out my Youtube channel with all kinds of cool videos including LP's which I'm currently working at. Don't forget to give feedback as well. ;)


Offline Sambolinski

  • Gold Member
  • *
  • Posts: 282
    • View Profile
    • Awards
Re: Learning to code for Gmod
« Reply #2 on: May 31, 2014, 04:18:24 PM »
At the moment I'm still learning but I started making a few SWEPS to get the feel of how the language works. Now I can make a SWEP without looking at the page for help. Look at this page to help you make a swep:

http://wiki.garrysmod.com/page/Chair_Throwing_Gun

Furthermore, you are going to know the syntax of Lua so this link might help:
http://www.lua.org/manual/5.1/manual.html

Offline wakeboarderCWB

  • Gold Member
  • *
  • Posts: 2,486
  • Awards [OCRP Award] Social Player [OCRP Award] You Own The Mall [OCRP Award] Dedicated Player [OCRP Award] Millionaire
    • View Profile
    • Awards
Re: Learning to code for Gmod
« Reply #3 on: May 31, 2014, 04:40:16 PM »
Lua isn't that hard to pick up at all, and it's a great starting language if you want to get into advanced programming(C/C++, C#, etc).

Read Programming in Lua here. It's made by the creators of Lua and though it is 2 editions old, it's still a great way to get started.

Take a look at Learn Lua in 15 Minutes here. You're not going to actually learn Lua in 15 minutes, however it's basically a tutorial written in code. The explanation is written in comments and explain what you're looking at.

When you get to coding for Garry's Mod, take a glance at the wiki here. If you find an undocumented page, take a look at the old wiki(Garry's Mod 12) here.

Lastly, just take a look at other people's work. See how other people write and try to figure out what their code does. You can even try to recreate their code, make it more efficient and whatnot.

As for text editors, I personally use Sublime Text 3 with the GMod Lua syntax highlighter. IF you do decide to use Sublime Text, install Package Control. It basically installs any plugin, theme, and syntax highlighter you want straight from Sublime Text. No need to Google anything, you just search for it in the text editor and it installs everything for you. If you don't want to buy Sublime Text, use Notepad++ with the GMod Lua syntax highlighter.

Also, note that you will not remember everything. For every project you work on, you will have to reference something or Google something. Every programmer does this and don't let it make you feel like you're a bad coder.

As with any programming language, there are ways to do things and then there are better, more efficient ways to do things. You'll learn these as you progress. When coding for GMod, take note of efficiency. Be careful of your server-client networking, make sure you're checking, setting, or sending things only when you need to(As in, don't be sending a player's amount of money to the client every tick, only send it when it's updated).
« Last Edit: May 31, 2014, 04:43:23 PM by wakeboarderCWB »

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal