SHARE
TWEET

Untitled

a guest Jan 28th, 2020 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ndb.valid = {
  2.   orgs = {
  3.     "gaudiguch",
  4.     "hallifax",
  5.     "celest",
  6.     "magnagora",
  7.     "glomdoring",
  8.     "serenwilde",
  9.   },
  10. }
  11.  
  12. function kfs.saveConfig()
  13.   table.save(getMudletHomeDir() .. "/kfs/config.lua", kfs.config)
  14.   table.save(getMudletHomeDir() .. "kfs/config_dict.lua", kfs.configDict)
  15. end
  16.  
  17. function kfs.loadConfig()
  18.   if kfs.config and kfs.configDict then
  19.     return kfs.config,kfs.configDict
  20.   else
  21.     local config,configDict = {},{}
  22.     if io.exists(getMudletHomeDir().."/kfs/config.lua") then -- if one exists, we can probably safely assume the other does too
  23.       table.load(getMudletHomeDir().."/kfs/config.lua", config)
  24.       table.load(getMudletHomeDir().."/kfs/config_dict.lua", configDict)
  25.     else
  26.       -- initialize default configs if they don't already exist
  27.       config = {
  28.         echoColor = "light_yellow",
  29.         allheale = false,
  30.         useCustomPrompt = false,
  31.         customPrompt = "",
  32.         warnWidth = 50,
  33.         ndb = {
  34.           paused = false,
  35.           highlight = {
  36.             gaudiguch = true,
  37.             hallifax = true,
  38.             celest = true,
  39.             magnagora = true,
  40.             glomdoring = true,
  41.             serenwilde = true,
  42.             rogue = true,
  43.             divine = true,
  44.             watch = true,
  45.           },
  46.           colors = {
  47.             gaudiguch = "OrangeRed",
  48.             hallifax = "LightSkyBlue",
  49.             celest = "RoyalBlue",
  50.             magnagora = "firebrick",
  51.             glomdoring = "DarkViolet",
  52.             serenwilde = "ForestGreen",
  53.             rogue = "ansiWhite",
  54.             divine = "gold",
  55.             watch = "green",
  56.           },
  57.         }, -- end ndb config defaults
  58.       } -- end config
  59.       configDict = {
  60.         allheale = {
  61.           optionType = "boolean",
  62.           onEnabled = function()
  63.             kfs.echof("<green>Will<%s> use allheale to cure.", kfs.config.echoColor)
  64.           end,
  65.           onDisabled = function()
  66.             kfs.echof("<red>Won't<%s> use allheale to cure.", kfs.config.echoColor)
  67.           end,
  68.         },
  69.         echoColor = {
  70.           optionType = "string",
  71.           onSet = function()
  72.             kfs.echof("Default echo color changed to %s", kfs.config.echoColor)
  73.           end,
  74.         },
  75.         useCustomPrompt = {
  76.           optionType = "boolean",
  77.           onEnabled = function()
  78.             kfs.echof("<green>Will<%s> display custom prompt.", kfs.config.echoColor)
  79.           end,
  80.           onDisabled = function()
  81.             kfs.echof("<red>Won't<%s> display custom prompt.", kfs.config.echoColor)
  82.           end,
  83.         },
  84.         customPrompt = {
  85.           optionType = "string",
  86.           onSet = function()
  87.             kfs.echof("Custom prompt string has been set to: \n%s", kfs.config.customPrompt)
  88.           end,
  89.         },
  90.         warnWidth = {
  91.           optionType = "number",
  92.           onSet = function()
  93.             kfs.echof("Warning message width set to: <green>%s", kfs.config.warnWidth)
  94.           end,
  95.         },
  96.         ndb = {
  97.           paused = {
  98.             optionType = "boolean",
  99.             onEnabled = function()
  100.               kfs.echo("Name highlighting is now <red>PAUSED.")
  101.             end,
  102.             onDisabled = function()
  103.               kfs.echo("Name highlighting is now <green>UNPAUSED.")
  104.             end,
  105.           },
  106.           highlight = {
  107.             rogue = {
  108.               optionType = "boolean",
  109.               onEnabled = function()
  110.                 kfs.echof("<green>Will<%s> highlight rogues.", kfs.config.echoColor)
  111.               end,
  112.               onDisabled = function()
  113.                 kfs.echof("<red>Won't<%s> highlight rogues.", kfs.config.echoColor)
  114.               end,
  115.             },
  116.             divine = {
  117.               optionType = "boolean",
  118.               onEnabled = function()
  119.                 kfs.echof("<green>Will<%s> highlight divine.", kfs.config.echoColor)
  120.               end,
  121.               onDisabled = function()
  122.                 kfs.echof("<red>Won't<%s> highlight divine.", kfs.config.echoColor)
  123.               end,
  124.               },
  125.             watch = {
  126.               optionType = "boolean",
  127.               onEnabled = function()
  128.                 kfs.echof("<green>Will<%s> highlight names on the watch list.", kfs.config.echoColor)
  129.               end,
  130.               onDisabled = function()
  131.                 kfs.echof("<red>Won't<%s> highlight names on the watch list.", kfs.config.echoColor)
  132.               end,
  133.             },
  134.           },
  135.           colors = {
  136.             divine = {
  137.               optionType = "string",
  138.               onSet = function()
  139.                 kfs.echof("Will highlight divine in: <%s>%s.", kfs.config.ndb.colors.divine, kfs.config.ndb.colors.divine)
  140.               end,
  141.             },
  142.             rogue = {
  143.               optionType = "string",
  144.               onSet = function()
  145.                 kfs.echof("Will highlight rogues in: <%s>%s.", kfs.config.ndb.colors.rogue, kfs.config.ndb.colors.rogue)
  146.               end,
  147.             },
  148.             watch = {
  149.               optionType = "string",
  150.               onSet = function()
  151.                 kfs.echof("Will highlight watchlist names in: <%s>%s.", kfs.config.ndb.colors.watch, kfs.config.ndb.colors.watch)
  152.               end,
  153.             },
  154.           },
  155.         }, -- end ndb configDict
  156.       } -- end configDict
  157.       -- set up config dict entries for orgs
  158.       for _,org in pairs(ndb.valid.orgs) do
  159.         configDict.ndb.highlight[org] = {
  160.           optionType = "boolean",
  161.           onEnabled = function()
  162.             kfs.echof("<green>Will<%s> highlight citizens of %s", kfs.config.echoColor, org:title())
  163.           end,
  164.           onDisabled = function()
  165.             kfs.echof("<red>Won't<%s> highlight citizens of %s", kfs.config.echoColor, org:title())
  166.           end,
  167.         }
  168.         configDict.ndb.colors[org] = {
  169.           optionType = "string",
  170.           onSet = function()
  171.             kfs.echof("Will now highlight citizens of %s in: <%s>%s", org:title(), kfs.config.ndb.colors[org], kfs.config.ndb.colors[org])
  172.           end,
  173.         }
  174.       end
  175.     end
  176.     return config,configDict
  177.   end
  178. end
  179.  
  180. kfs.config, kfs.configDict = kfs.loadConfig()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top