Posted 14 April 2013 - 12:05 PM
Hi together,
For the Program im working on, at the moment, i would like to use the ccConfig API, from bit.
to get known how to work with it, i wanted to check the example File and play with it a bit.
But its not working. Infos as follwing:
Setup:
- API file is in the Main Folder of the Computer
- named ccConfig without any extention
Error: line 6 attempt to index ? (a nil value)
Other Notes
- added an empty file Named config.cfg – Same error
- when i change the first line to os.loadAPI("blabla") or os.loadAPI(" ") i dont get an error
- tried to use os.loadAPI("ccConfig") instead of os.loadAPI("/ccConfig")
i think loadapi should give an error if i try to load a file that does not exist but im not sure
maybe you can help
edit: forgot the code its the example code from bit :D/>
Thanks in advance
Loki
For the Program im working on, at the moment, i would like to use the ccConfig API, from bit.
to get known how to work with it, i wanted to check the example File and play with it a bit.
But its not working. Infos as follwing:
Setup:
- API file is in the Main Folder of the Computer
- named ccConfig without any extention
Error: line 6 attempt to index ? (a nil value)
Other Notes
- added an empty file Named config.cfg – Same error
- when i change the first line to os.loadAPI("blabla") or os.loadAPI(" ") i dont get an error
- tried to use os.loadAPI("ccConfig") instead of os.loadAPI("/ccConfig")
i think loadapi should give an error if i try to load a file that does not exist but im not sure
maybe you can help
edit: forgot the code its the example code from bit :D/>
os.loadAPI("/ccConfig")
term.clear()
term.setCursorPos(1,1)
local conf = ccConfig.new("config.cfg")
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")))
Thanks in advance
Loki
Edited on 14 April 2013 - 10:36 AM