Garry's Mod

Garry's Mod

Not enough ratings
Partly Adequate Configuration Manager
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Tool
Addon Tags: Fun
File Size
Posted
Updated
56.492 KB
2 Jan, 2022 @ 6:27am
31 Jan, 2022 @ 2:52pm
3 Change Notes ( view )

Subscribe to download
Partly Adequate Configuration Manager

Description
A powerful module for creating and managing settings.

Basics
  • Addons can use this module to create powerful settings with minimal effort.
  • This addon doesn't provide it's own ui. You can use this or create your own.

Settings
  • Settings are organized in a tree
  • There are three trees of settings
    • Client Settings
      • Client sided settings which are independent from the server
    • Client Overrides
      • Server sided settings which will override the values of client sided settings with a matching id
      • will be networked to all clients
      • only clients with permission are allowed to change these
    • Server Settings
      • server sided settings
      • will be networked to all clients
      • only clients with permission are allowed to change these

Dependencies
  • Addons can provide game properties (values that represent a state the game is in, like the current map's name, the current gamemode or the player count)
  • Settings can depend on game properties
    • It's possible to provide a list of sources, which contain information on how the setting's value should change for different states the game property can be in.
    • Sources are settings and can therefore depend on game properties themselves.

What does pacoman help with exactly?
  • The settings are automatically stored in- and loaded from the client and server sided databases
  • Benefits over convars
    • The settings are organized
    • Settings can have values that depend on the game's current state without any additional work for developers.
    • Settings can be of any type as long as you provide the necessary functions.
    • The Server can provide overrides for client settings
    • UI can be automatically generated (see: Pacoman UI)
    • Less of a pain to quickly create a new setting.
  • Downsides
    • clients know all values of server sided settings

Brief introduction on how to use this
  • Use Pacoman
    • You need to load the module before using any of it's functions.
    • require("pacoman")
  • Create a namespace
    • Namespaces can contain settings or other namespaces
    • Use these to structure your settings.
    • Two settings/namespaces inside the same namespace can not share the same name.
    • Pacoman provides three root namespaces: pacoman.server_settings, pacoman.client_settings and pacoman.client_overrides
    • local example_namespace = pacoman.server_settings:AddChild("example")
  • Create a setting
    • Settings need a type and a value that fits the given type.
    • Pacoman provides some default types. You can also create your own.
    • example_setting = example_namespace:AddSetting("example", pacoman.TYPE_INTEGER, 30)
    • to retrieve a setting's value you should use the GetActiveValue() function on the setting table.
    • local value = example_setting:GetActiveValue()

  • Create a type
    • You need to provide an id, a validator, a serializer and a deserializer.
    • Providing a comparator is optional, but allows sources of settings to work on intervals instead of specific values which is often desired.
      • The comparator needs to take two values of the wanted type as parameters and return true if the first value is smaller than the second.
    • local function CompareNumber(value_1, value_2) return value_1 <= value_2 end TYPE_EXAMPLE = pacoman.RegisterType("example", isnumber, tostring, tonumber, CompareNumber)
  • Create a game property
    • A game property needs a unique id, a type and an initial value.
    • A game property's value can be updated using the SetValue function.
    • This example creates a game property that holds the current number of players.
    • local ply_count = 0 local gp_player_count = pacoman.RegisterGameProperty("player_count", pacoman.TYPE_INTEGER, ply_count) hook.Add("PlayerConnect", "UpdatePlayerCountProperty", function(ply) ply_count = ply_count + 1 gp_player_count:SetValue(ply_count) end) hook.Add("PlayerDisconnected", "UpdatePlayerCountProperty", function(ply) ply_count = ply_count - 1 gp_player_count:SetValue(ply_count) end)

Known Problems
  • I have not tested this in multiplayer
  • A lot of data is networked once a player connects. With too many settings it automatically kicks players because of networking limitations. (A possible solution would be to merge multiple net messages and compress them, but I haven't yet found the time to adjust this. Feel free to create a pr :D)

Additional Information
  • Please report bugs here[github.com], if you find any. (Bugs are to be expected since I didn't test it in multiplayer lol)
  • The source code is available here[github.com] and the api is fully documented.
14 Comments
vinno 17 Jul, 2023 @ 1:00pm 
so how do I edit the settings? Is there some text file?
xav07theboi 24 Apr, 2023 @ 9:33am 
nvm
xav07theboi 24 Apr, 2023 @ 9:14am 
the command to load the menu is gone
Reispfannenfresser  [author] 31 Aug, 2022 @ 1:37am 
@DukeofLeet I sent you a friend request. We can move to discord from there if you want.
DukeofLeet 30 Aug, 2022 @ 1:16pm 
If you could get in contact with me I can demonstrate whats going on.
Reispfannenfresser  [author] 30 Aug, 2022 @ 1:27am 
@DukeofLeet
I just did some tests and I can not reproduce the issue.
Reispfannenfresser  [author] 29 Aug, 2022 @ 10:51am 
That is an interesting issue.
I'll look into this.
Thanks for reporting!
DukeofLeet 27 Aug, 2022 @ 1:36pm 
Im having an issue where the client_overrides are not actually effecting any of the client settings on my server. "[PACOMAN] Client overrides loaded." even shows up in the server console, but the extensions do not seem to be enabling as I set them to.
Reispfannenfresser  [author] 3 Jul, 2022 @ 2:25pm 
The settings are stored in the client- and server sided database.
cd0m 2 Jul, 2022 @ 8:26pm 
Where is the file for this config located?