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

-_- Help!

Started by IsaacTBeast, 14 March 2014 - 06:01 AM
IsaacTBeast #1
Posted 14 March 2014 - 07:01 AM
Umm I have a problem… Everytime I open the file

it shows this:
paintutils:92:attempt to get length of nil

here in this code:

--Desktop
--Created By: IsaacTBeast
--Learned By: IsaacTBeast
--Closed Source. You cannot copy this code and make it to your own self with out permission to me..
--fLib was created by: NDFJay
--I write the code by hand not by copying it to others..
os.loadAPI("/.astro/system/api/fLib")

slc = 0
tBarC=128
local tBartC = 2
textC = 2
backColor= 1
contextX = 0
iConText="File Manager"
iCon="/.astro/system/images/.icon"
iConLink="/Programs/filema"
iCon2="/.astro/system/images/unicon2"
iConText2="Simple Pastebin"
iConLink2="/Programs/pastebinsi"
systemFile="/.astro/system/.kernel/astro.lua"
backGroundC=
term.setBackgroundColor(backColor)
term.clear()
--Title Bar
function titleBar()
term.setCursorPos(1,1)
term.setBackgroundColor(tBarC)
term.setTextColor(tBartC)
term.clearLine()
term.setCursorPos(2, 1)
print("[Astro]")
end
function titleBar2()
term.setCursorPos(36,1)
term.setBackgroundColor(tBarC)
term.setTextColor(tBartC)
print("[System Config]")
end
function titleBar3()
term.setCursorPos(1,1)
term.setBackgroundColor(tBarC)
term.setTextColor(tBartC)
term.clearLine()
term.setCursorPos(2,1)
print("[Exit]")
end
function drawDesktop()
  term.setBackgroundColor(backColor)
  term.clear()
  bground = paintutils.loadImage("/.astro/system/image/background")
  icon = paintutils.loadImage(iCon)
  icon2 = paintutils.loadImage(iCon2)
  paintutils.drawImage(icon2, 2, 12)
  paintutils.drawImage(icon, 2, 3)
  paintutils.drawImage(bground,1,1)
  term.setBackgroundColor(backColor)
  term.setCursorPos(1,9)
  term.setTextColor(colors.red)
  print("+")
  term.setCursorPos(2,10)
  term.setTextColor(128)
  print(iConText)
  term.setTextColor(colors.red)
  term.setCursorPos(1,17)
  print("+")
  term.setTextColor(128)
  term.setCursorPos(2, 18)
  print(iConText2)
  titleBar()
  titleBar2()
end
function drawMenu1()
  term.setCursorPos(1,2)
  print("		  ")
  term.setCursorPos(1,3)
  print(" Shutdown ")
  term.setCursorPos(1,4)
  print(" Restart  ")
  term.setCursorPos(1,5)
  print("		  ")
end
function drawMenu2()
  term.setBackgroundColor(128)
  term.setTextColor(256)
  term.setCursorPos(contextX, contextY)
  print("			 ")
  term.setCursorPos(contextX, contextY+1)
  print(" Edit Gui    ")
  term.setCursorPos(contextX, contextY+2)
  print(" FileManager ")
  term.setCursorPos(contextX, contextY+3)
  print("			 ")

end
function drawMenu3(iX, iY)
  term.setBackgroundColor(128)
  term.setTextColor(256)
  term.setCursorPos(iX, iY)
  print("		 ")
  term.setCursorPos(iX, iY+1)
  print(" Rename  ")
  term.setCursorPos(iX, iY+2)
  print(" Chan-Icon ")
  term.setCursorPos(iX, iY+3)
  print(" Re-Link ")
  term.setCursorPos(iX, iY+4)
  print("		 ")
end
function drawMenu4()
term.setBackgroundColor(128)
term.setTextColor(256)
term.setCursorPos(36,2)
print("			   ")
term.setCursorPos(36,3)
print(" C-Background  ")
term.setCursorPos(36,4)
print("			   ")
end
drawDesktop()
while true do
local event,button, X, Y = os.pullEventRaw("mouse_click")
  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
		  elseif X >= 2 and X <= 5 and Y >= 3 and Y <= 9 and button == 1 then
		  shell.run(iConLink)		
		    elseif X >= 1 and Y >= 2 and button == 2 then slc = 2
			  if  X >=38 then
			  contextX = 38
			  end
			  if Y >=14 then
			  contextY = 14
			  end
			  if X <= 38 then
			  contextX = X
			  end
			  if Y <= 14 then
			  contextY = Y
			  end
			  drawMenu2()
			    elseif X == 1 and Y == 9 and button == 1 then slc = 3
				  drawMenu3(1,11)
				    elseif X >= 2 and X <= 6 and Y >= 12 and Y <= 15 and button == 1 then
					  shell.run(iConLink2)
					    elseif X == 1 and Y == 18 and button == 1 then slc = 3
						  drawMenu3(1,18)
						   elseif X >= 36 and X <= 50 and Y == 1 then slc = 4
							 drawMenu4()
								  
	    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   
elseif slc == 2 then
	  if X >= contextX and X <= contextX+13 and Y == contextY+1 and button == 1 then slc = 0
	    shell.run("edit", "gui")
	    drawDesktop()
		  elseif X >= contextX and X <= contextX+13 and Y == contextY+2 and button == 1 then slc = 0
		    shell.run("file")
		    drawDesktop() 
			   else
			    slc = 0
			    drawDesktop()   
			 
	   end
    elseif slc == 3 then
	  if X >= 1 and X <= 12 and Y == 12 and button == 1 then
	  term.setTextColor(256)
	  term.setBackgroundColor(backColor)
	  term.setCursorPos(2,10)
	  print("		 ")
	  term.setCursorPos(2,10)
	  input = read()
	  fLib.replaceLine(systemFile,16,'iConText="'..tostring(input)..'"')
	  return
	  shell.run(systemFile)
  
		  elseif X >= 1 and X <= 12 and Y == 13 and button == 1 then
			 term.setBackgroundColor(128)
			 lY = 8
			  for i =1,3 do
			  term.setCursorPos(18, lY)
			  print("					 ")
			  lY = lY+1
			  end
			    term.setBackgroundColor(256)
			    term.setTextColor(1)
			    term.setCursorPos(19, 9)
			    print("				   ")
			    term.setCursorPos(20,9)
			    input = read()
			    fLib.replaceLine(systemFile,17,'iCon="'..tostring(input)..'"')
			    return
			    shell.run(systemFile)
				   elseif X >= 1 and X <= 12 and Y == 14 and button == 1 then
					 term.setBackgroundColor(128)
					   lY = 8
			 
					   for i = 1,3 do
					   term.setCursorPos(18,lY)
					    print("					    ")
					   lY = lY+1
					   end
					   term.setBackgroundColor(256)
					   term.setCursorPos(19, 9)
					   print("					  ")
					 term.setCursorPos(20,9)
					  term.setTextColor(1)
					  input = read()
					 fLib.replaceLine(systemFile, 18,'iConLink="'..tostring(input)..'"')
					 return
					 shell.run(systemFile)
				
				
							  
			    else
			    slc = 0
			    drawDesktop()
			   end
				 elseif slc == 4 then
				    if X >= 36 and X <= 50 and Y == 3 and button == 1 then
					   term.setBackgroundColor(128)
						 lY = 8
						
						 for i = 1, 3 do
						 term.setCursorPos(18,lY)
						 print("						 ")
						 lY = lY+1
						 end
						 term.setBackgroundColor(256)
						 term.setCursorPos(19,9)
						 print("					   ")
						 term.setCursorPos(20,9)
						 term.setTextColor(1)
						 input = read()
						 fLib.replaceLine(systemFile,56, 'bground= paintutils.loadimage("'..tostring(input)..'")')
	   return
	   shell.run(systemFile)
						 else
						 slc = 0
						 drawDesktop()
  
			
 
	    end
   
	 end
   end

please help me.
theoriginalbit #2
Posted 14 March 2014 - 07:05 AM
you're loading an image somewhere and then trying to draw it, however the problem lies in wherever you're loading the image; you're giving it the wrong file path and the image is failing to load.
IsaacTBeast #3
Posted 14 March 2014 - 07:09 AM
huh?? I give the right path look at the code..
CometWolf #4
Posted 14 March 2014 - 07:18 AM
Looking at the code dosen't help us, since we don't know the correct file path. One of the images you are loading do not exist, you'll have to figure out which yourself.
IsaacTBeast #5
Posted 14 March 2014 - 07:22 AM
Sorry for that… I forgot to change the path to "/.astro/system/images" not "/.astro/system/image" LOL SORRY!

Case Save..
CometWolf #6
Posted 14 March 2014 - 07:29 AM
If it happens again, put this at the top of your code. It should tell you what image failed to load with an error.

local paintutils = setmetatable(
  { 
    loadImage = function(path)
      local image = _G.paintutils.loadImage(path)
      assert(image,"Attempted to load faulty image "..path.."!")
      return image
    end
  },
  {
    __index = _G.paintutils
  }
)
IsaacTBeast #7
Posted 14 March 2014 - 07:33 AM
thanks ComeWolf.