Posted 09 December 2014 - 12:39 AM
Lately I have been working on an OS for computercraft, and I plan to use a few 3rd party APIs in my OS. I am planning to use the ccConfig API and the md5 API (not made for computercraft, but it should work, right?). However, after loading the APIs (no error in the loading), it returns an error claiming that whatever line is calling the first function from either of the APIs is "Attempt to index ? (a nil value)". I have followed the documentation completely on ccConfig (as it's the one I need the most), but no matter how long I look at my own code, I cannot find anything that could be causing this error.
My code:
If you need anything else, please let me know.
ALSO: I am using CCEmuRedux, if that makes any difference.
My code:
os.loadAPI ("/bin/APIs/ccConfig.lua")
local conf = ccConfig.new ("/System/Library/Config/UI.cfg", "Config for 'LionUI.lua'")
local deskBcol
local deskTcol
local wallpaper
local dockStyle
local falicon
local function loadConfig ()
conf.load ()
deskBcol = conf.getColor ("deskBcol", 8)
deskTcol = conf.getColor ("deskTcol", 32768)
wallpaper = conf.getString ("wallpaper", "/System/Library/Images/aqua.nfp")
dockStyle = conf.getString ("dockStyle", "Saved")
falicon = conf.getString ("falicon","&")
conf.save ()
end
local function finderBar (state, arg1, arg2, arg3, arg4, arg5)
if state == 0 then
term.clear ()
term.setCursorPos (1, 1)
term.setBackgroundColor (1)
term.clearLine ()
term.setCursorPos (2, 1)
term.setTextColor (2048)
print (tostring (falicon))
term.setCursorPos (5, 1)
term.setTextColor (32768)
print ("Finder")
term.setCursorPos (13, 1)
term.setTextColor (128)
print ("File Edit View Go Help")
term.setCursorPos (50, 1)
term.setTextColor (2048)
print ("?")
elseif state == 1 then
term.clear ()
term.setCursorPos (1, 1)
term.setBackgroundColor (1)
term.clearLine ()
term.setCursorPos (2, 1)
term.setTextColor (2048)
print ("@")
term.setCursorPos (5, 1)
term.setTextColor (32768)
print (arg1)
term.setCursorPos (string.len (arg1) + 7, 1)
term.setTextColor (128)
print (arg2)
term.setCursorPos (string.len (arg1) + string.len (arg2) + 9, 1)
term.setTextColor (128)
print (arg3)
term.setCursorPos (string.len (arg1) + string.len (arg2) + string.len (arg3) + 11, 1)
term.setTextColor (128)
print (arg4)
term.setCursorPos (string.len (arg1) + string.len (arg2) + string.len (arg3) + string.len (arg4) + 13, 1)
term.setTextColor (128)
print (arg5)
term.setCursorPos (50, 1)
term.setTextColor (2048)
print ("?")
end
end
local function finderDock (style)
local function loadIcons ()
ico1 = paintutils.loadImage ("/System/Library/Icons/finder.nfp")
ico2 = paintutils.loadImage ("/System/Library/Icons/dashboard.nfp")
ico3 = paintutils.loadImage ("/System/Library/Icons/mail.nfp")
ico4 = paintutils.loadImage ("/System/Library/Icons/images.nfp")
ico5 = paintutils.loadImage ("/System/Library/Icons/terminal.nfp")
ico6 = paintutils.loadImage ("/System/Library/Icons/preferences.nfp")
ico7 = paintutils.loadImage ("/System/Library/Icons/place.nfp")
ico8 = paintutils.loadImage ("/System/Library/Icons/place.nfp")
ico9 = paintutils.loadImage ("/System/Library/Icons/place.nfp")
ico10 = paintutils.loadImage ("/System/Library/Icons/place.nfp")
end
local function drawIcons ()
paintutils.drawImage (ico1, 7, 17)
paintutils.drawImage (ico2, 11, 17)
paintutils.drawImage (ico3, 15, 17)
paintutils.drawImage (ico4, 19, 17)
paintutils.drawImage (ico5, 23, 17)
paintutils.drawImage (ico6, 27, 17)
paintutils.drawImage (ico7, 31, 17)
paintutils.drawImage (ico8, 35, 17)
paintutils.drawImage (ico9, 39, 17)
paintutils.drawImage (ico10, 43, 17)
end
if style == "full" then
term.setCursorPos (1, 16)
term.setBackgroundColor (256)
term.clearLine ()
term.setCursorPos (1, 17)
term.clearLine ()
term.setCursorPos (1, 18)
term.clearLine ()
term.setCursorPos (1, 19)
term.clearLine ()
loadIcons ()
drawIcons ()
elseif style == "saved" then
dock = paintutils.loadImage ("/System/Library/Images/dock-saved.nfp")
paintutils.drawImage (dock, 6, 16)
loadIcons ()
drawIcons ()
end
end
function initGUI (state)
if state == 0 then
finderBar (0)
finderDock (dockStyle)
else
finderBar (1, "[NIL]", "WIP", "Sorry, not implemented yet", " ", " ")
finderDock (dockStyle)
end
end
function finder ()
initGUI (1)
end
finder ()
If you need anything else, please let me know.
ALSO: I am using CCEmuRedux, if that makes any difference.