• File Structure
    5 replies, posted
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 :) I'm kinda used to coding now, and just went to do this and not sure how it would work :D [B][U][I]Or[/I][/U][/B] 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.
[QUOTE=Semajnad;44990090]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 :) I'm kinda used to coding now, and just went to do this and not sure how it would work :D [B][U][I]Or[/I][/U][/B] 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.[/QUOTE] One autorun file to include them all ( this wants a LoTR reference ) and then just have any directory inside the lua folder. like: [lua] lua/autorun/include.lua lua/semajnad/inv/<lua stuff> lua/semajnad/char/<lua stuff> lua/semajnad/hud/<lua stuff> lua/semajnad/xp/<lua stuff> [/lua]
[QUOTE] One autorun file to include them all ( this wants a LoTR reference ) [/QUOTE] You are so right lol [QUOTE=HumbleTH;44990191] [lua] lua/autorun/include.lua lua/semajnad/inv/<lua stuff> lua/semajnad/char/<lua stuff> lua/semajnad/hud/<lua stuff> lua/semajnad/xp/<lua stuff> [/lua][/QUOTE] 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 include.lua include("../semajnad/char/init.lua") does init.lua get autoran as well?
[QUOTE=Semajnad;44990275]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 include.lua include("../semajnad/char/init.lua") does init.lua get autoran as well?[/QUOTE] 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 ) [lua] if SERVER then AddCSLuaFile() 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 end 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 end [/lua]
[QUOTE=HumbleTH;44990412]= -snip [/QUOTE] [CODE] local dir = "../modules/" for file = file.Find( dir .. "*" .. "/sv_*.lua", "LUA" ) then include( file ) end [/CODE] Would I not have to go up a directory as include : [QUOTE] The file name must not include ".." - this is the special folder name to go up a folder. [B]The filename is relative to the current directory.[/B] [/QUOTE]
[QUOTE=Semajnad;44990611][CODE] local dir = "../modules/" for file = file.Find( dir .. "*" .. "/sv_*.lua", "LUA" ) then include( file ) end [/CODE] Would I not have to go up a directory as include :[/QUOTE] Looking at pointshops one, it's relative to Lua, but I'm not too sure anyways.
Sorry, you need to Log In to post a reply to this thread.