Starting on SWep, not sure where to place main folder.

Ok, I decided enough learning, it’s time to get into Lua hands on. Problem is, the last time I played G-Mod (A few weeks ago) there was a Gamemodes -> Sandbox folder I waas going to put the SWep in, now (Due to a recent update from what I’ve read) I don’t even have a gamemode folder. So my question is, how should I set up the file hierchy now? [My main thought is to just make a gamemodes folder, but I really don’t want to spend all day working on setting it up, that’s why I’m hoping for a faster solution so I can get started on the SWep.]


No one has any words of advice? It seems the G-Mod updates have also broken the entire gamemodes folder, and the drop-down menu for selecting the gamemode while playing Garry’s Mod. I did make a gamemodes folder, made a gamemode, and filled it with the correct files, but that didn’t work either.

Just put your weapon in an lua/weapons/weaponnamefolder/shared.lua, that will solve your weapon problem. But I don’t know how to get it in a gamemode folder

Not a good idea. You should make a folder for yourself in the “addons” folder, this way, it’s easy to share your stuff with people.
Here is how your folder should be organized:

	<name of your addon>
				<name of your weapon class>
				<name of another weapon class>

Every folder located inside of the addons folder needs a file inside called info.txt. It’s just there to tell the game to load your addon and identify it. You can copy it from any addon you want, and modify whatever you want.

Weapons go in lua\weapons, and there is one folder for each weapon class. The class of the weapon is the name which will be used for registering the weapon in the game, it should be lowercase, and it should not contain spaces. Usually, it starts with “weapon_”, for instance, “weapon_test”, but that’s just a naming convention.

Inside of this folder, you will need to create three Lua files called init, cl_init, and shared. init.lua should contain only serverside code, cl_init.lua should contain only clientside code, and shared.lua may contain code shared between both sides.
init and cl_init are not strictly needed, actually, a lot of scripted weapons don’t use them. Most beginners put most of the code in shared.lua, you can do that, but you should make sure you know when something should be executed only on the server, or only on the client.

As for Lua coding itself, just read the wiki.



I remember your name, last time I played with you, you seemed like a fairly smart guy, just read the wiki and you shouldn’t have any trouble.

Sounds good Killburn, I was thinking of just making it into an addon, but I thought just making the gamemodes folder would be a little more simplistic since I am going to need one later on, I suppose I can just copy the Swep files for the gamemode later I suppose. Thanks for the help.

Be careful, if you are going you move your files to a gamemode folder, weapons go in gamemodes/<your gamemode name>/gamemode/entities/weapons. Gamemodes also require an info.txt.

There are a bunch of little oddities like that, but with some common sense and observation, you’ll easily figure them out by yourself.