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

PaintUtils error-ing

Started by JSpartan250, 02 March 2014 - 08:19 PM
JSpartan250 #1
Posted 02 March 2014 - 09:19 PM
Hello,

I have just started to play around with the "paintutils" API and made a program (A startup program)
​I have tried to draw an Image to the screen, but I have no success in doing so.
If you wan't to view the code, go here!

Thanks,
JSpartan250
CometWolf #2
Posted 02 March 2014 - 09:33 PM
What does your image file look like? Im assuming you actually drew it with the paint program?

Edit: I took a look at the paintutils API

function loadImage( sPath )
	    local tImage = {}
	    if fs.exists( sPath ) then
			    local file = io.open(sPath, "r" )
			    local sLine = file:read()
			    while sLine do
					    local tLine = {}
					    for x=1,sLine:len() do
							    tLine[x] = tColourLookup[ string.byte(sLine,x,x) ] or 0
					    end
					    table.insert( tImage, tLine )
					    sLine = file:read()
			    end
			    file:close()
			    return tImage
	    end
	    return nil
end
This will only return nil if the file you give it dosen't exist, so… does "IMG/Test" even exist?
Edited on 02 March 2014 - 08:42 PM
JSpartan250 #3
Posted 03 March 2014 - 07:58 AM
What does your image file look like? Im assuming you actually drew it with the paint program?

Edit: I took a look at the paintutils API

function loadImage( sPath )
		local tImage = {}
		if fs.exists( sPath ) then
				local file = io.open(sPath, "r" )
				local sLine = file:read()
				while sLine do
						local tLine = {}
						for x=1,sLine:len() do
								tLine[x] = tColourLookup[ string.byte(sLine,x,x) ] or 0
						end
						table.insert( tImage, tLine )
						sLine = file:read()
				end
				file:close()
				return tImage
		end
		return nil
end
This will only return nil if the file you give it dosen't exist, so… does "IMG/Test" even exist?

Thanks for that.
Don't know what happened, but I just came back on and it somehow worked :D/>
Thanks,
JSpartan250