This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
NeptunasLT's profile picture

paintutils:92: attempt to get length of nil

Started by NeptunasLT, 16 February 2013 - 06:04 AM
NeptunasLT #1
Posted 16 February 2013 - 07:04 AM
I getting this error My code:


–ArchilyOS Desktop

slc = 0
tBarC = 8
tBartC = 1
backColor = 1
term.setBackgroundColor(backColor)
term.clear()
function titleBar()
term.setCursorPos(1,1)
term.setBackgroundColor(tBarC)
term.setTextColor(tBartC)
term.clearLine()
term.setCursorPos(3, 1)
print("[SYSTEM]")
end
function drawDesktop()
term.setBackgroundColor(backColor)
term.clear()
bground = paintutils.loadImage("/archily/system/.background")
paintutils.drawImage(bground,1,1)
titleBar()

end

function drawMenu1()
term.setTextColor(256)
term.setBackgroundColor(128)
term.setCursorPos(1,2)
print(" ")
term.setCursorPos(1,3)
print(" Shutdown ")
term.setCursorPos(1,4)
print(" Restart ")
term.setCursorPos(1,5)
print(" ")

end

drawDesktop()
while true do
local event, button, X, Y = os.pullEventRaw()
if slc == 0 then
if event == "mouse_click" then
if X >=2 and X <=8 and Y==1 and button ==1 then
drawMenu1()
slc = 1
else
drawDesktop()
end
end
elseif slc == 1 then
if X >=1 and X <=11 and button == 1 and Y== 3 then slc = 0
os.shutdown()
elseif X>=1 and X<=11 and Y==4 and button ==1 then slc = 0
os.reboot()
else
slc = 0
drawDesktop()

end
end
end
Where is the Problem?
tesla1889 #2
Posted 16 February 2013 - 07:11 AM
what is at /archily/system/.background?

this would make sense if that file didn't exist or was an empty file
bjornir90 #3
Posted 16 February 2013 - 07:12 AM
The problem is in the paintutils API as suggered in the error message, but I think it is caused by the fact that you put a wrong path for the loadImage. In CC you should put the extension of the file, in this case it should be .nfp
Edit : ninja'ed