Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("/ccConfig")
- term.clear()
- term.setCursorPos(1,1)
- local conf = ccConfig.new("config.cfg", "Basic Config Example")
- local running
- local msg
- local rate
- local bgcolor
- local txtcolor
- local function loadConfig()
- conf:load()
- running = conf:getBoolean("canRun", "no")
- msg = conf:getString("welcomeMessage", "Hello World")
- rate = conf:getNumber("refreshRate", 2.5)
- bgcolor = conf:getColor("background", colors.black)
- txtcolor = conf:getColour("text", "colors.white")
- conf:addCommentForKey("canRun", "Tells the program if it is allowed to run")
- conf:addCommentForKey("refreshRate", "Tells the program how often to check inputs again")
- conf:save()
- end
- local function resetConfig()
- conf:reset()
- conf:save()
- end
- loadConfig()
- print("This should display whats in the configs:")
- print("canRun: "..tostring(running)) --> whats in config or false
- print("msg: "..msg) --> whats in config or "Hello World"
- print("rate: "..rate) --> whats in config or 2.5
- print("bg: "..bgcolor)
- print("text: "..txtcolor)
- print("canRun key exists: "..tostring(conf:containsKey("canRun")))
- print("thisThing key exists: "..tostring(conf:containsKey("thisThing")))
- resetConfig()
- loadConfig()
- print("\nThis should display whats the default values are:")
- print("canRun: "..tostring(running)) --> whats in config or false
- print("msg: "..msg) --> whats in config or "Hello World"
- print("rate: "..rate) --> whats in config or 2.5
- print("bg: "..bgcolor)
- print("text: "..txtcolor)
- print("canRun key exists: "..tostring(conf:containsKey("canRun")))
- print("thisThing key exists: "..tostring(conf:containsKey("thisThing")))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement