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

Problem with paintutils.loadImage()

Started by axel.codeFail(), 15 April 2014 - 01:31 AM
axel.codeFail() #1
Posted 15 April 2014 - 03:31 AM
I'm attempting at the beginning of an OS and I'm trying to make a little loading screen, but i'm having troubles with it.

I'm getting

paintutils:92: attempt to get length of local 'tImage' (a nil value)

in the directory data/img/os/ there are two images, img.OS1 and img.OS2. but for some reason, it only loads the first, data/img/os/img.OS1 then throws the error.

The name of the program is os.load. (Just in case it matters)


shell.run("clear")
--Image Loading Func
function loadImage(dir,x,y)
  img=paintutils.loadImage(dir)
  paintutils.drawImage(img,x,y)
end
----
shell.run("cd //")
----
--Tables
img = {"data/img/os/img.OS1","data/img/os/img.OS2",}
--
for i=1,5 do
  loadImage(tostring(img[1]),1,1)
  sleep(.5)
  loadImage(tostring(img[2]),1,1)
  sleep(.5)
end
Pic
pastebin get jXMHcT6A
Bomb Bloke #2
Posted 15 April 2014 - 04:04 AM
After defining "img" as a table with a pair of strings, you then redefine it as a new table with image data in it when running the "loadImage()" function.

Don't overwrite "img".
axel.codeFail() #3
Posted 15 April 2014 - 04:11 AM
After defining "img" as a table with a pair of strings, you then redefine it as a new table with image data in it when running the "loadImage()" function.

Don't overwrite "img".


Facepalm

I didn't even notice that.
Thanks.