Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ndb.valid = {
- orgs = {
- "gaudiguch",
- "hallifax",
- "celest",
- "magnagora",
- "glomdoring",
- "serenwilde",
- },
- }
- function kfs.saveConfig()
- table.save(getMudletHomeDir() .. "/kfs/config.lua", kfs.config)
- table.save(getMudletHomeDir() .. "kfs/config_dict.lua", kfs.configDict)
- end
- function kfs.loadConfig()
- if kfs.config and kfs.configDict then
- return kfs.config,kfs.configDict
- else
- local config,configDict = {},{}
- if io.exists(getMudletHomeDir().."/kfs/config.lua") then -- if one exists, we can probably safely assume the other does too
- table.load(getMudletHomeDir().."/kfs/config.lua", config)
- table.load(getMudletHomeDir().."/kfs/config_dict.lua", configDict)
- else
- -- initialize default configs if they don't already exist
- config = {
- echoColor = "light_yellow",
- allheale = false,
- useCustomPrompt = false,
- customPrompt = "",
- warnWidth = 50,
- ndb = {
- paused = false,
- highlight = {
- gaudiguch = true,
- hallifax = true,
- celest = true,
- magnagora = true,
- glomdoring = true,
- serenwilde = true,
- rogue = true,
- divine = true,
- watch = true,
- },
- colors = {
- gaudiguch = "OrangeRed",
- hallifax = "LightSkyBlue",
- celest = "RoyalBlue",
- magnagora = "firebrick",
- glomdoring = "DarkViolet",
- serenwilde = "ForestGreen",
- rogue = "ansiWhite",
- divine = "gold",
- watch = "green",
- },
- }, -- end ndb config defaults
- } -- end config
- configDict = {
- allheale = {
- optionType = "boolean",
- onEnabled = function()
- kfs.echof("<green>Will<%s> use allheale to cure.", kfs.config.echoColor)
- end,
- onDisabled = function()
- kfs.echof("<red>Won't<%s> use allheale to cure.", kfs.config.echoColor)
- end,
- },
- echoColor = {
- optionType = "string",
- onSet = function()
- kfs.echof("Default echo color changed to %s", kfs.config.echoColor)
- end,
- },
- useCustomPrompt = {
- optionType = "boolean",
- onEnabled = function()
- kfs.echof("<green>Will<%s> display custom prompt.", kfs.config.echoColor)
- end,
- onDisabled = function()
- kfs.echof("<red>Won't<%s> display custom prompt.", kfs.config.echoColor)
- end,
- },
- customPrompt = {
- optionType = "string",
- onSet = function()
- kfs.echof("Custom prompt string has been set to: \n%s", kfs.config.customPrompt)
- end,
- },
- warnWidth = {
- optionType = "number",
- onSet = function()
- kfs.echof("Warning message width set to: <green>%s", kfs.config.warnWidth)
- end,
- },
- ndb = {
- paused = {
- optionType = "boolean",
- onEnabled = function()
- kfs.echo("Name highlighting is now <red>PAUSED.")
- end,
- onDisabled = function()
- kfs.echo("Name highlighting is now <green>UNPAUSED.")
- end,
- },
- highlight = {
- rogue = {
- optionType = "boolean",
- onEnabled = function()
- kfs.echof("<green>Will<%s> highlight rogues.", kfs.config.echoColor)
- end,
- onDisabled = function()
- kfs.echof("<red>Won't<%s> highlight rogues.", kfs.config.echoColor)
- end,
- },
- divine = {
- optionType = "boolean",
- onEnabled = function()
- kfs.echof("<green>Will<%s> highlight divine.", kfs.config.echoColor)
- end,
- onDisabled = function()
- kfs.echof("<red>Won't<%s> highlight divine.", kfs.config.echoColor)
- end,
- },
- watch = {
- optionType = "boolean",
- onEnabled = function()
- kfs.echof("<green>Will<%s> highlight names on the watch list.", kfs.config.echoColor)
- end,
- onDisabled = function()
- kfs.echof("<red>Won't<%s> highlight names on the watch list.", kfs.config.echoColor)
- end,
- },
- },
- colors = {
- divine = {
- optionType = "string",
- onSet = function()
- kfs.echof("Will highlight divine in: <%s>%s.", kfs.config.ndb.colors.divine, kfs.config.ndb.colors.divine)
- end,
- },
- rogue = {
- optionType = "string",
- onSet = function()
- kfs.echof("Will highlight rogues in: <%s>%s.", kfs.config.ndb.colors.rogue, kfs.config.ndb.colors.rogue)
- end,
- },
- watch = {
- optionType = "string",
- onSet = function()
- kfs.echof("Will highlight watchlist names in: <%s>%s.", kfs.config.ndb.colors.watch, kfs.config.ndb.colors.watch)
- end,
- },
- },
- }, -- end ndb configDict
- } -- end configDict
- -- set up config dict entries for orgs
- for _,org in pairs(ndb.valid.orgs) do
- configDict.ndb.highlight[org] = {
- optionType = "boolean",
- onEnabled = function()
- kfs.echof("<green>Will<%s> highlight citizens of %s", kfs.config.echoColor, org:title())
- end,
- onDisabled = function()
- kfs.echof("<red>Won't<%s> highlight citizens of %s", kfs.config.echoColor, org:title())
- end,
- }
- configDict.ndb.colors[org] = {
- optionType = "string",
- onSet = function()
- kfs.echof("Will now highlight citizens of %s in: <%s>%s", org:title(), kfs.config.ndb.colors[org], kfs.config.ndb.colors[org])
- end,
- }
- end
- end
- return config,configDict
- end
- end
- kfs.config, kfs.configDict = kfs.loadConfig()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement