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

[Lua] [Error] paintutils:94: attempt to get length of nil

Started by ScoutCD10, 26 October 2012 - 09:23 AM
ScoutCD10 #1
Posted 26 October 2012 - 11:23 AM
When i try to make my picture to appear on my monitor it says
paintutils:94: attempt to get length of nil
CODE

mon = peripheral.wrap("right")
paintutils.loadImage("creeper")
paintutils.drawImage("creeper",0,0)
Espen #2
Posted 26 October 2012 - 11:43 AM
If you take a look at the api help ( "help paintutils" ) you'll see that paintutils.drawImage() expects an image as an input and not a file.
And image, in this case, means a table, which "creeper" is not.^^

You have to store the return value of paintutils.loadImage() in a variable and feed that to paintutils.drawImage(), like so:
local myImage = paintutils.loadImage("creeper")
paintutils.drawImage(myImage, 0, 0)

Cheers

EDIT: Changed variable name to a more sensible one.
Leo Verto #3
Posted 05 November 2012 - 11:04 AM
This isn't a bug, Unicorn Guy, move this plox!