• Gamemode file structure.
    37 replies, posted
I've been scripting for quite a long time and I can script anything I can imagine but I am having issues organising my files. So heres my quick question: What should the file structure look like, like where to put what.
Uh, what? You don't know where to put weapons and entities to?
[QUOTE=Robotboy655;42583476]Uh, what? You don't know where to put weapons and entities to?[/QUOTE] No, it's just that you can't make a gamemode by putting everything in cl_init, init and shared because it will be really, really, really messy. @Edit: I know where to put entities and such, I just don't know how to organise and what files to create, like if I have player releated functions - where should they be located.
I just make a new file for each really important feature like rounds, player extension, etc that might just be me though
[QUOTE=rejax;42583496]I just make a new file for each really important feature like rounds, player extension, etc that might just be me though[/QUOTE] And what do you put in player ext., every function that uses Playermeta ?
Well, I would suggest keeping it kinda modular, like I do with stranded: All panels are on one file, day/night is in another, processes are defined in third, basic stuff goes into init.lua/cl_init.lua/shared.lua, but it is really a matter of personal preference. Like I'm not creating a separate file for each panel/process/item because of the .lua script limit.
Like Robotboy said, keep the key features seperate, but don't have too many files. At the same time you want to be able to look at the files and know where you'd find a specific function.
I usually organize my gamemodes like this: [t]http://puu.sh/4UDnX.png[/t] Basic gamemode functions like [I]GM:Move()[/I] or [I]GM:ShouldCollide()[/I] go into the 'hooks' folder. Extensions to default GMod/standard Lua libraries go into 'extensions'. Modules such as custom libraries and whatnot go into the 'modules' folder (90% of everything goes there), and I think you can guess what 'player_class' holds. I almost exclusively keep things like startup routines and the like in the 3 base files 'init', 'shared' and 'cl_init'. I usually also keep a 'vgui' folder for VGUI elements, but as this is for a gamemode base those go somewhere else.
[QUOTE=EvacX;42583579]I usually organize my gamemodes like this: [t]http://puu.sh/4UDnX.png[/t] Basic gamemode functions like [I]GM:Move()[/I] or [I]GM:ShouldCollide()[/I] go into the 'hooks' folder. Extensions to default GMod/standard Lua libraries go into 'extensions'. Modules such as custom libraries and whatnot go into the 'modules' folder, and I think you can guess what 'player_class' holds. I almost exclusively keep things like startup routines and the like in the 3 base files 'init', 'shared' and 'cl_init'. I usually also keep a 'vgui' folder for VGUI elements, but as this is for a gamemode base those go somewhere else.[/QUOTE] that looks fairly easy to modify in the future as you can put new stuff into modules and disable it at any times.
[img]http://puu.sh/4VuhQ.png[/img] My failed attempt to keep my gamemode folder clean.
Uhm, in the past, I've just stuck most of the stuff inside init.lua After looking at this thread, I'm rather tempted to start cleaning things up a little bit.
[img]http://i.imgur.com/NGvqpl5.png[/img] Seems to have worked well so far -- pretty much the same as EvacX's, I guess.
DarkRP's folder structure used to be terrible, but in 2.5.0 I've thrown things around a bit: [img]http://i.imgur.com/cnxU5ie.png[/img] The only files in gamemode/ are cl_init.lua and init.lua. They load the modules. Since everyone wants to modify everything in DarkRP, all modules can be dynamically enabled or disabled. In fact, some modules are disabled by default. People can write their own modules, but I'd rather have them add these modules in the official modification addon. You will want two things in your folder structures: - low coupling - high cohesion Low coupling means you can disable/remove a module (or another kind of "part") and have the rest still working. High cohesion means that you want one module (or one "part") to be responsible for one thing. e.g. the F4menu module handles the F4 menu and nothing more.
[QUOTE=FPtje;42597015] You will want two things in your folder structures: - low coupling - high cohesion Low coupling means you can disable/remove a module (or another kind of "part") and have the rest still working. High cohesion means that you want one module (or one "part") to be responsible for one thing. e.g. the F4menu module handles the F4 menu and nothing more.[/QUOTE] I also do something like this. I just like to code everything as a modular addon Like this : [IMG]http://i.imgur.com/CU78b6g.png[/IMG] [IMG]http://i.imgur.com/8BNTJ9t.png[/IMG]
This thread is now "Pictures of your gamemode folders v1"
[QUOTE=Handsome Matt;42606741]Oh Snorlax.. Snorlax, Snorlax, Snorlax. That's nothing like what FPtje just said.[/QUOTE] Arent it? I understand he talking about it is a good idea to make something that can be turned off/on easy.
I already have a general idea as of how it should look and I am following it. I've put functions into some sort of libraries and these libraries into separate files. For example, functions releated to the inventory are stored in GP.inventory = {} in a file called 'inventory.lua'
[QUOTE=Handsome Matt;42606741]Oh Snorlax.. Snorlax, Snorlax, Snorlax. That's nothing like what FPtje just said.[/QUOTE] I'm dying right now.
[QUOTE=Koolaidmini;42632542]I'm dying right now.[/QUOTE] Because he couldnt spell my name right. He missed S all time
It's people like Snorlaxs that sometimes make me ashamed of being Danish :v: (don't listen to Facepunch, I am actually from Daneland).
[QUOTE=EvacX;42639457]It's people like Snorlaxs that sometimes make me ashamed of being Danish :v: (don't listen to Facepunch, I am actually from Daneland).[/QUOTE] Daneland isnt a word. Guess i need to have some learn you some grammar like i did to Matt
[QUOTE=Snorlaxs;42639625]Daneland isnt a word. Guess [B]i[/B] need to have some learn you some grammar like i did to Matt[/QUOTE] I "need to have some learn you some grammar" - What? Also it's called teach.
Snorlaxs, just stop. You are making a fool of yourself, and when you are 'correcting' people, you get it wrong. I.E: The personal pronoun 'I' should always be capitalised, no matter where it is in the sentence. This is not meant as a snipe, a dig, or what ever you want to call it. Just trying to avoid further embarrassment for you.
No i want to annoy Matt more. He annoy me and say i should goto school (Even though i was at school) offtopic : Facepunch broken it says im writing from a Mac (I dont Even pwm something from Apple this is a Android phone)
[QUOTE=Snorlaxs;42640145]He annoy me and say i should goto school (Even though i was at school[/QUOTE] After reading that I think you need to pay more attention at school
[QUOTE=King Penisless;42640152]After reading that I think you need to pay more attention at school[/QUOTE] It is called "breaks"
This...this is a trainwreck.
In my experience the most important thing you can do in your organization is to prefix all your files (other than init, sh_init and cl_init) with cl_ sh_ or sv_. That way you know what you're editing. Dividing into core and extention folders also helps.
excl im sorry but youre a few broken sentences too late
[QUOTE=Handsome Matt;42641093]this thread went to shit as soon as Snorlaxs posted[/QUOTE] The exact thing I was thinking.
Sorry, you need to Log In to post a reply to this thread.