How to start out?

Hey,

Got interested in programming after I registered here and checked this section, it’s pretty neat what people can create with lua in gmod.

So i’m curious on how to get started, i’m willing to learn, and i have minor experience in programming, so guide me to where i can start learning, and if somebody here is an expert, it would be amazing if i could add you on steam so you can help me whenever c:

thanks

I am pretty new to glua (garry’s mod lua) myself (as you can see with my immense amount of stupid questions). I started out learning a bit of Java, and with that coding knowledge, I moved to lua. I watched MyCosmicSeagull’s tutorial videos for a start, and then continued learning via experimentation, the wiki and facepunch (the stupid questions I mentioned before).
Now, please keep in mind that this is just the way I learned to script glua. You might want to take another route, as it’s probably not suitable for everyone.

<<< Add me on steam and spam me all you want with stupid questions.

Read don’t just watch.
Practice don’t just observe.
Anything you want to do that is easy has been asked before and has been answered, never make a new thread and if you cant find an answer for the question use the Problems that dont need a thread thread.

Try things yourself and do some research. Don’t waste people’s time for what can be found on Google or the wiki. If you can’t get it right or can’t find it, feel free to ask.

Add me on steam if you ever need help.

Also look here http://wiki.garrysmod.com/page/Main_Page for stuff you might find “fun” and just go at it.

Thank you all for the support, I really appreciate it! <3

I can provide help as well, just PM me and I should be able to give you some assistance.

If you want to get into scripting in lua, I reccomend you download this addon;

It’s an interactive, in-game script editor and executor. Any method that you find on the wiki, serverside or clientside, can be run in the editor, and it should allow you to practice messing around with the various glua functions and hooks.

Here’s a simple beginner’s program. Type this into the luapad;


PrintMessage(3, "Hello World!")

Then click the “Run script” button at the top, and run it on the server; it should print the message “Hello World!” to the chat.

The best advice I can give you is this:

  • Think of some project you want to make. Maybe a system for an already existing gamemode or something. Try not to go too overboard with this (starting out with a gamemode).
  • Write/think out what this will entail; what you’ll need to do to players or entities or data, etc.
  • Use the wiki (already been linked) to find functions that will help you accomplish these things.
  • If you get stuck, make a post here and we’ll try to help you out. If it’s small, it can go in Problems That Don’t Need Their Own Thread (as AnonTakesOver said)
  • Move on to a more difficult or of different type project.

Also since no one has linked code_gs’ thread… http://forum.facepunch.com/showthread.php?t=1337945

Just a question. Why’d you not use “print” instead? And why is there a three inside the brackets?

Thank you everyone!

The command PrintMessage() is built in to Garry’s Mod Lua; it allows you to print a message to the chat. If you were to use print(), then it would only print into the console, and you’d have to open it up to see the message.

The 3 in the first argument for PrintMessage actually dictates where it should print the message. It can be anywhere from 1-4, but people don’t use 1 because it doesn’t work. If you put a 2 in there, then it prints the message to the console; a 3, and it prints to chat, and if you put a 4, then it splashes the text in front of your character in big white letters for a couple seconds. This is all defined at the HUD enums page: http://wiki.garrysmod.com/page/Enums/HUD.
You can actually substitute any of those numbers for their respective enum names in your code, because they’re enums, and act like predefined variables that can’t be changed. For example, this code below;


PrintMessage(HUD_PRINTTALK, "Hello World!")

Will work exactly the same as the above code I quoted before, because HUD_PRINTTALK is equivalent to the number 3. Doing it this way is easier to read and remember if you aren’t able to recall what numbers are for which enums off the top of your head, like I can.

I tutor and have written quite a lot of tutorials ( working on getting my site up so they’ll all be in one place instead of drop-box )…

Feel free to add me to Steam. Also, I suggest setting up SRCDS to write code: https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/setting_up_a_server_with_steamcmd.lua.html

If you want a blank slate to start with to code, or if you want a nice little dev game-mode to create things ( where you don’t have to worry about including files, etc… ) then try my dev-base. It is auto-refresh compatible, or if you’re running linux you can enable smart auto-refresh ( so changes are networked to you ), etc…

Also, use Sublime or Notepad++ as an editor… The links below will walk you through setting up Notepad++

Here are some links and a wall of text:

I have written over 500 tutorials and completed “systems” in Lua for Garry’s Mod. I tutor for negotiable rates / free / donations, and answer questions on on one for free / donations; feel free to add me on Steam if you need some guidance. Here are some resources to help you get started:

Generalized Lua Help ( Links to Wikis, Answers the question of “Where do I post a simple question or DarkRP Specific question”, links to other resources compiled by forum members )
https://dl.dropboxusercontent.com/u/26074909/tutoring/___welcome_docs/_welcome_general_lua_learning.lua.html

Useful Programs ( SteamCMD, Autosizer, Desktops, Process Explorer ) and Notepad++ Upgrades
https://dl.dropboxusercontent.com/u/26074909/tutoring/___welcome_docs/_welcome_useful_programs_and_notepadpp_upgrades.lua.html

If you’re looking for an “empty” game-mode to start developing on ( for creating addons in an environment meant for dev work, developing a new game-mode, etc… ) which has a lot of building-blocks to make development easier, and dev-tools for debugging, etc… I recommend running my dev-base ( supports smart-autorefresh for Linux or Windows with -disableluarefresh )

AcecoolDev_Base Skeletonized Game-Mode ( Never worry about Include or AddCSLuaFile ever again; comes with New Hooks, Console Commands, Meta-Table Objects, Helper Functions, Extended Functionality, and more! )

AcecoolDev_Networking: Only has the networking and data system with required files. Also has UMSG to NetMSG Conversion Mapper and will eventually include NW/DT/etc… Var map through networking system…

AcecoolDev_Base Addon - All of the features above, but packaged as an addon.

Find out more and Download here: https://dl.dropboxusercontent.com/u/26074909/tutoring/___welcome_docs/_welcome_acecooldev_base_gamemode_info.lua.html

Thank you so much for all that information. I’ve added you on Steam so we can talk further, thank you SO much!