A flexible server config system parsed by Lua, an alternative to cfg.
When you have people administrate your server, they probably don't understand lua that well, yet there might be times where they need to change lua. Luacfg solves this problem by bridging the gap between lua and cfg, allowing devs to provide admins with a user-friendly way of changing lua.
While Source's cfg is not that different, it's bound by ugly Source limitations such as maximum # of commands.
Devs define luacfg commands in their lua code, luacfg recursively parses files in cfg/luacfg/, Admins write to cfg/luacfg/
Developer, inside your lua:
hook.Add("luacfg.Initialized", "put_a_unique_value_here", function()
luacfg.AddCommand("cat_lives", function(args)
local lives = args[1]
if !lives then return end
file.Write("how-many-lives.txt", lives)
end)
end)
Admin, inside cfg/luacfg/cat.luacfg (you can call it whatever):
cat_lives "9"
Restart. You should now have a file data/how-many-lives.txt that reads 9. Luacfg!
Developer Hooks
- luacfg.Initialized
- Ready for creation of commands
- luacfg.LoadFiles
- Files were loaded from a directory
- dir (string)
- luacfg.LoadFile
- A file was loaded
- file (string)
Developer Methods
- luacfg.AddCommand
- Adds a new luacfg command
- name (string)
- function (arguments [table])
- Returns nil
- luacfg.ParseCommand
- Parses a command from provided string
- command (string)
- Returns command (string), arguments (table)
- This is used internally..
- luacfg.LoadFile
- Loads file containing commands
- file path (string)
- Returns nil
- This is used internally..
- luacfg.LoadFiles
- Recursively loads all files in specified directory, or cfg/luacfg if not specified.
- dir (string)
- Returns nil
- This is used internally..