Getting Started on a Gamemode

Hi, I’ve wanted to create a gamemode for a long time, and while I don’t have a particular idea right at the moment, I’d like to learn the essentials of creating a gamemode. I have recently set up a gmod community running DarkRP, however I have realised just how mingey it really is - I’d like to create some sort of roleplay style gamemode, though I’m yet to decide.

I’ve done some coding in the past (VB.NET) and am quite comfortable with general programming concepts, however have never used Lua before. I’ve done some research on the official gmod wiki and the maurits wiki (the old official wiki?), and have found a couple of (outdated) guides. However I have also seen some things about Fretta, which is said to be easier to start as it already has a lot of the hooks and generic code for me to use.

So a few questions:

  • Should I use Fretta as a first-timer?
  • Could you recommend any decent guides/tutorials that are updated to gmod 13, and are the existing outdated ones good enough?
  • Should I forget about creating a gamemode for now and start with something else like a HUD or a SWEP?

Cheers

Fretta is basically dead. I think jetboom released a gmod 13 stable version, though.
As for guides, the best guide i could think to offer is simply telling you to read through lua code until you begin to understand it. that’s how i learned what little i know, anyways.

As for forgetting about the gamemode, it’s completely up to you. if you like to jump into stuff then by all means go right on ahead and do so. if you like learning slow, i suggest you start out with SWEPs / Entities. I guarantee that you’ll basically understand them down pat within a couple days of devoted study/practice.

It all comes down to usurping off of other’s work in the end. don’t feel bad if you copypasta other people’s code, by the way. I still do it all the time and honestly i don’t think there’s shame in doing so.
Just dont copy an entire addon and call it specifically yours, that drifts into rude credit-stealing.

Hope my reply was useful, and good luck with learning the language!

Ok, thanks Archemyde for the detailed reply. I think I’ll mess around with SWEPs first to get a hang of how gmod handles Lua. I had a look at the code for DarkRP but it seems rather too complicated for me at the moment.

I actually found doing the logical part of the gamemode easier than a HUD or the VGUI components when I first started. It’s really helped me to learn Lua quickly. I look back on the earlier work in my gamemode and think “what the heck did I do this for?”, which is to be expected really
One thing I found challenging was the OOP aspect of Lua, since it differed so much from the OOP styles of C# I was used to. After getting my head around it, I learned to love the Lua way of OOP. I’m sure you’ll get the same feeling coming from VB, if you ever used OOP in that.

Thankfully for you, Lua likes keywords such as ‘not’ and ‘and’ to perform bitwise comparisons as well as the equivalent “!” and “&&”, so coming from VB shouldn’t be too hard.

As Archemyde said, learn from other people. I don’t suggest copying entire chunks of code, though there’s no harm in doing so as long as you absolutely understand what the code is doing and you know you’d be able to write it yourself.

I didn’t learn Entities/SWEPS first, I found them a bit too abstract. Jumping in and getting a simple gamemode running is what I’d do. It’s not really even throwing yourself in at the deep end, I understand gamemodes better than I do entities/SWEPS

Haha now I’m undecided! I guess the lesson I can take from this is just to learn from other people’s code, that seems like the best way to learn. Now, what is the difference between using base vs. sandbox as my base gamemode? They seem to have different ‘hooks’, however I’m uncertain whether one is better in general. I noticed that DarkRP uses Sandbox as a base.

As a rule of thumb, if your gamemode involves building (basewards, flood, RP, etc.) use sandbox as a base. Otherwise, use base (the gamemode all gamemodes inherit)

Do what you feel is more comfortable. Making a SWEP or something might be fun, but I know I don’t enjoy it as much as making a core gamemode, everyone is different though