Jump to content




Problem with paintutils.loadImage()


  • You cannot reply to this topic
2 replies to this topic

#1 axel.codeFail()

  • Members
  • 47 posts
  • LocationA bit lost

Posted 15 April 2014 - 02: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

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 15 April 2014 - 03: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".

#3 axel.codeFail()

  • Members
  • 47 posts
  • LocationA bit lost

Posted 15 April 2014 - 03:11 AM

View PostBomb Bloke, on 15 April 2014 - 03:04 AM, said:

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users