Posted 23 February 2013 - 07:05 PM
Hi guys, I would like to know if anyone can fix this, at the moment, only 1 pixel is being drawn and will eventually give: paintutils To long without yielding, blah blah….
Can anyone help me?
Also how does the "for" loop thing work?
Can anyone help me?
Also how does the "for" loop thing work?
os.loadAPI("w")
function checkColour(number)
if (number == 0) then
return 32768
elseif (number == 1) then
return 2048
elseif (number == 2) then
return 16384
elseif (number == 3) then
return 16
elseif (number == 4) then
return 8192
elseif (number == 5) then
return 2
elseif (number == 6) then
return 1024
elseif (number == 7) then
return 64
elseif (number == 8) then
return 128
elseif (number == 9) then
return 1
elseif (number == nil) then
return 32768
end
end
function imageRead(dir,file)
term.clear()
term.setCursorPos(1,1)
local iline = 1
local ichar = 1
local ix = 1
local iy = 1
repeat
local dline = w.split(w.read(dir,file,iline),",")
repeat
local colour = checkColour(tonumber(dline[ichar]))
paintutils.drawPixel(ix,iy,colour)
local ichar = ichar +1
local ix = ix +1
until (dline[ichar] == nil)
local iline = iline +1
local iy = iy +1
until (dline == nil)
end
imageRead("/","image")