File Structure

Need a bit of help finding a good file structure, as I’m unsure how to do this.

If I wanted to make a large Dark RP mod, that had different parts to it. For example, I’ve got:

Inventory System,
Character Creation
HUD (chat box, health, armor, money )
Experience / Leveling

What’s the best way to do it, should each one be a seperate Addon. If so, can they talk to each other? For example, if I needed to say if you reach level 10 put an item in slot 1 on inventory system. If they are all autoran individually, can I use functions from each one? How would I do this?

Sorry for the nooby question :slight_smile: I’m kinda used to coding now, and just went to do this and not sure how it would work :smiley:


Is it better to do it all as one addon? Can I do addons > my_addon > lua > modules > DIRECTORIES? Would they all have to autorun etc? I hope someone knows what I mean as I barely do.

One autorun file to include them all ( this wants a LoTR reference ) and then just have any directory inside the lua folder.



lua/semajnad/inv/<lua stuff>
lua/semajnad/char/<lua stuff>
lua/semajnad/hud/<lua stuff>
lua/semajnad/xp/<lua stuff>

You are so right lol

So if I file is included in an autorun file, does that file also get autoran?

[editline]3rd June 2014[/editline]

eg: lua/autorun/include.lua


does init.lua get autoran as well?

Yes. And you don’t need to go up a dir, just put the path relative to the lua dir. So if your init.lua file is in lua/semajnad/char/init.lua, you include( “semajnad/chat/init.lua” )

And you need to AddCSLuaFile() the clientside and shared files, as well as include clientside and shared files on client. Sorta like this ( ignore messy code )
if SERVER then
AddCSLuaFile( “sh_player_ext.lua” )
AddCSLuaFile( “store.lua” )
AddCSLuaFile( “weapons.lua” )
AddCSLuaFile( “scoreboard_colors.lua” )
AddCSLuaFile( “hooks.lua” )
AddCSLuaFile( “perks.lua” )
AddCSLuaFile( “vgui/menu.lua” )
// AddCSLuaFile() other clientsides and shareds

include( "store.lua" )
include( "rewards.lua" )
include( "sh_player_ext.lua" )
include( "weapons.lua" )
include( "scoreboard_colors.lua" )
include( "hooks.lua" )
include( "perks.lua" )
// include() other serversides and shareds


if CLIENT then
include( “store.lua” )
include( “sh_player_ext.lua” )
include( “weapons.lua” )
include( “scoreboard_colors.lua” )
include( “hooks.lua” )
include( “perks.lua” )
include( “vgui/menu.lua” )
// include() other clientsides and shareds

local dir = "../modules/"

for file = file.Find( dir .. "*"  .. "/sv_*.lua", "LUA" ) then
	include( file )

Would I not have to go up a directory as include :

Looking at pointshops one, it’s relative to Lua, but I’m not too sure anyways.