New game mode from scratch

I just have to quickly gripe: the gmod documentation seems scattered and much of it out of date. Even the official garry’s mod wiki has tutorials that don’t work. I followed creating a game mode tutorial from there to the letter, yet I’m having some trouble. So before I ask is there an up to date development document I’m unaware of?

So, here’s my game mode so far:

It didn’t show up in the global game mode list online until I added and empty info.txt file

Isn’t this a throwback from the previous version(s)? If so, why am I having to do that now?

The next problem I had was that players spawn without any weapons including the tool gun.
In my

file I have



"citylife"
{
	"base"			"sandbox"
	"title"			"City Life"
	"maps"			"^cl_"
	"menusystem"	"1"

	"settings"
	{
		1
		{
			"name"		"cl_propstayafterdisconnect"
			"text"		"Time props stay after owner disconnect"
			"help"		"Time props stay after owner disconnect in minutes"
			"type"		"numeric"
			"default"	"60"
		}
	}
}


So it seems it doesn’t derive anything from the base game mode, which is set to

I can use Lua to manually give players their default stuff but I don’t know how to enable the usual prop menu.

DeriveGamemode(“Sandbox”) in shared.lua if you haven’t already

In order to use sandbox as a base in your gamemode you should have


DeriveGamemode( "sandbox" )

in your “shared.lua” file somewhere.

I read this was for version prior to Gmod 13? I added it and works, so thanks for that.

If you want something to make development easier: Please look into AcecoolDev_Base, a skeletonized-developer-base game-mode which features an autoloader ( to ignore ever needing to use include or AddCSLuaFile ever again, plus console commands to force the game-mode to refresh “loadgm”, and to easily changelevel “relevel/remap <Current Map OR optionally mapname> <Current GM OR optionally gamemode>” ), many new and useful hooks, many helper-functions, many metatable “classes”, and much more.

My networking system ( lightweight version ) will be included in the near future along with a few other nice surprises.

It is recommended that you use a form of GIT/SVN software to allow for easy updating.
Src: https://bitbucket.org/Acecool/acecooldev_base/src/
Issue-Tracker: https://bitbucket.org/Acecool/acecooldev_base/issues/
Pull-Requests: https://bitbucket.org/Acecool/acecooldev_base/pull-requests/
Wiki: https://bitbucket.org/Acecool/acecooldev_base/wiki/Home/

Basically, never worry about AddCSLuaFile or include ever again, plus some helper functions, metatables, etc…

Didn’t I tell you something about advertising your “super awesome scripts”?

I don’t know, did you? What makes you so important that I must bow down to you and follow any of your wishes? The world doesn’t revolve around you, and if it bothers you to see people helping other people out then I feel really really bad for your parents that probably buy you new toys and get yelled at because it isn’t the right color.

I also hope that you’re not the one that calls my mothers house threatening her with other kids giggling in the background.

Doesn’t this thread cover making a new game-mode from scratch with some bumps along the way? By using my skeleton, it is essentially drag and drop files, follow the readme to rename the game-mode, and never worry about include/AddCSLuaFile ever again with the bonus of including a bunch of helper functions, updated metatable / objects, etc… In short, I added something relevant to the topic, did you?

So, regardless of whether or not the OP wants to use the skeletonized game-mode with all of the features, the readme to rename the game-mode will help in making the ops game-mode show up in game, or there may be a function or two the OP wants to use.

Also, to the OP. I tutor a lot of people on Steam. Feel free to add me if you’re looking for one on one help. I’ve written close to 400 tutorials, and climbing, so if you have a question just ask. As I tell everyone else, don’t ask to ask, just ask.

your skeleton isn’t scratch tho

It is if you consider the fact that it doesn’t contain game-mode logic, only an automated file loader and more functions to build a game-mode from.

Otherwise it is like saying an empty game-mode folder isn’t scratch because Garry’s Mod functions are included.

I think learning about your skeleton gamemode rather than simply learning the basic GMod documentation (include and AddCSLuaFile are basic functions to get Lua loaded, you shouldn’t be scared of it) will take longer. The helper functions aren’t that much to brag about either.

[lua]
//
// Simple helper to fire lock on an entity - Josh ‘Acecool’ Moser
//
function META_ENTITY:Lock( _time )
self:Fire( “lock”, “”, _time || 0 );
end
[/lua]

I mean honestly. One file for this?

ace, your trying to give a baby a fleshlight and expect its dick to fit

help the dude on his level instead of giving him shit that’s 500 times more complicated than it needs to be.

You also don’t need documentation to learn about adding GM.Name = “Gamemode Name Appears Here” in shared.lua

Your purpose for creating this skeleton gamemode is to make Lua coding for GMod easier but it everything way more complicated than it needs to be. Even the Lua style (regardless if whether or not you prefer it) looks confusing (no matter how many times you explain the underscores or what you do) to most which will make it harder for people trying to learn Lua. The overuse of C style syntax also looks odd when using Lua and will make it harder for those beginning to understand pure Lua syntax if they got use to your style which is in your skeleton gamemode.

You are “raising a new generation” of Lua coders in GMod with overly-complicated code and messy syntax.

I’m restructuring, and not all functions are implemented yet. Yes, I use one file per function in a lot of cases to make things easier to find. In the restructure, I’ll be using 1 file for many functions ( such as math, draw, surface, etc… library extensions ).

[editline]27th August 2014[/editline]

I offered to tutor, read up :slight_smile:

You’re going to reach the Lua file limit pretty fast that way then.

It covers ALL steps needed to rename, not just editing GM.Name; but to choose his own folder name, etc…

I didn’t realize you need a whole page of documentation to rename folders.

The limit is currently 8000. I reached it when addons like M9K were used ( without extracting to remove Lua files because I use my own base ). Also, there will be a production server build in the future ( essentially merging like-files together in proper load order ).

[editline]27th August 2014[/editline]

In the code I release, I add more comments and explanation that “needed” simply to help people understand the WHY something is done instead of just a brief explanation of what the algorithm as a whole does ( which is how I normally comment ).

Why don’t you just merge related functions so you don’t have to do it later.

I’m a bit of an organizational freak. When it comes to code, I dislike everything being in one file because it can make finding things a chore which is why I like the many files option so I can sort them under certain folders and know where to find x or y.
Now, if there is a metatable / object being written ( such as fileio which will be included in an update very soon, networking and data will also be included very soon ) and all functions are related then, yes, I will put it all in one file ( or 3 depending if something is clientside vs shared vs serverside ).

There are drawbacks such as the Lua file limit, but I’ve found an interesting way to get around the file limit. When you are in the game and you’ve hit the file limit: you can autorefresh / loadgm and the files that are missing will be sent to the client, so if you are over the limit you can still execute all of those files. Once they are in cache then it doesn’t matter, they’ll be loaded.

With the fileio, there is one function to combine all files from the list format that it generates. It looks like this ( old list, got rid of a lot of _s on file names ): https://dl.dropboxusercontent.com/u/26074909/tutoring/_file_structure/files_sh.txt

And combines them in the exact load order into 2 files ( such as init.lua and cl_init.lua ), making uploading a finished game-mode to production server easy and it can incorporate other filters such as removing blank new lines, removing all comments, obfuscating, etc… So, that will be one useful feature when everything is done if people choose to use it, if they don’t then there will be x number of files.

I may eventually fork the dev-base and do what you suggest so meta entity functions all go in 1 to 3 files, etc. BUT, when I do that I’ll use fileio to generate the mechanism for doing that so there won’t be massive maintenance to keep both forks up to date. Essentially update my end, type a command and have the files sent to my webserver and packaged in a zip with correct extensions instead of going into data and having to rename the .txt to .lua so that I only need to actively update ONE fork and have a system in place to pack up like functions into one file which will also serve as a demonstration as to what can be done with some of the building blocks that I aim to provide…

So, I agree that right now there aren’t really that many “good” functions in the release aside from the auto-loader, the hooks, and a few other things, but it’ll be built up as I add basic versions of some of the code I am running in my current dev. When the networking and data update is released, it’ll open a few more doors in terms of things to be included.

My goal is just to provide the easiest possible method to create a game-mode from scratch by including helper functions / building blocks that people can use. I heavily comment them so even an inexperienced user can read through it and understand what is happening line by line.

I’ll be rewriting TTT using this base and ensure that it is as optimized as possible; some of the game-modes I write / rewrite will be released for free with the base for people to learn from or run.

ace, you need to make a tally of how many times you put your name at the top of everything so that once you take over gmod 48 we can all know the ruler of the scripts since you could hit the lua file limit before TDM cars and m9k