Config file for derma

Hi,

So I’m doing a derma panel with mixed features for VIPs, and I wish to make it as and addons, so its easy to move around on my servers.

What I’m struggling with, is that I have a cl_init file, loacated in

What I wish to do, is to make it easy to config by having a config file.

I’ve seen coders using …Example.change… and then in their config file, they had something look-a-like

I hope you understand what I’m trying to say… But where would I place this config file, and what to include?

–Thanks

The way this kind of system works is by having global variables. You would perhaps make a config file like so;
[lua]
mymodconfig={}

mymodconfig.Name=“Test”
[/lua]

Then in your cl_init code you would refernce it like so
[lua]
local DermaPanel = vgui.Create( “DFrame” ) – Creates the frame itself
DermaPanel:SetPos( 50,50 ) – Position on the players screen
DermaPanel:SetSize( 1000, 900 ) – Size of the frame

DermaPanel:SetTitle( mymodconfig.Name ) – Title of the frame

DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true ) – Draggable by mouse?
DermaPanel:ShowCloseButton( true ) – Show the close button?
DermaPanel:MakePopup() – Show the frame
[/lua]

Becareful when using global tables and variables, since they can be modifed/accessed by all the files ran. So don’t use a generic name like “config”.

You’re my saviour.

However, how do I make it find the config file in cl_init?

And where to place the config file?

Thanks:rolleyes:

Probably not the most efficient way, maybe a “pro” lua coder can advise better, but here’s my method.

Make a new file called sh_config.lua in
addons/vip_perks/lua/autorun/

Then have it setup like so:

[lua]
//Shared Config
sh_mymodconfig={}


//Server Config
if SERVER then
sv_mymodconfig={}

end
//Client Config
if CLIENT then
cl_mymodconfig={}

end
[/lua]

You will then have your global tables set up and can then set them by referencing them.

Thanks, but do I need include the config file in cl_init.lua?
And how is that done, I know something about include("") and AddCS

If you want to, can you add me on steam for an instance?:smile:

If you put it in the folder I said, it should be automatically run at server start/map change on both client and server, If I remember.

If want to manually include it, then in your init script put:
AddCSLuaFile(“sh_config.lua”)
include( “sh_config.lua” )

In your cl_init.lua
include( “sh_config.lua” )

They are relative to where they were called.

Feel free to add me.