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

Load Image on Monitor

Started by gametechish, 17 March 2015 - 11:42 PM
gametechish #1
Posted 18 March 2015 - 12:42 AM
My program always spits the error

startup:5:attempt to call nil path
Here is the code:

logo = paintutils.loadImage("logo")
m = peripheral.wrap("monitor_0")
m.clear()
m.setCursorPos(1,1)
m.drawImage(logo,1,1)
and here is the image:


    eeeeeee   eeeeee    2222222	 e	   e
   e	   e  e	 e  2	   2    ee	  e
   e		  e	 e	  e	 2  e e	 e
   e		  e	 e		   22  e  e    e
    eeeeeee   eeeeee	   e	    e   e   e
		   e  e	  22    e	    e    e  e
		   e  e	  2	 e	    e	 e e
   e	   e  e	    2	   2    e	  ee
    eeeeeee   e		 2222222	 e	   e
Dragon53535 #2
Posted 18 March 2015 - 01:00 AM
As far as I know, there is no drawImage for monitors, perhaps you meant paintutils.drawImage
gametechish #3
Posted 18 March 2015 - 01:12 AM
I have tried that it failed
Zambonie #4
Posted 18 March 2015 - 01:19 AM
You can term.redirect to the monitor, but other then that no there isn't a method, unless someone makes a simple function that can do it, it shouldn't be really that hard.

I'll hop on a server quickly and code it, ill post a pastebin link to such a function ina sec. I'm bored.
Edited on 18 March 2015 - 12:20 AM
Zambonie #5
Posted 18 March 2015 - 01:35 AM

pastebin get MLHxfiZ5 drawmon

^draw image on monitor api

example of using it:


os.loadAPI("drawmon") --load the API
local m = peripheral.wrap("left") --or somewhere else
local image = paintutils.loadImage("/potato") --The Image to load
drawmon.drawImage(m, image, 2, 2) --draws my potato image at 2,2, supply the name of the monitor as the first parameter. in this case, m.

so bassicly in your own code it would look like this:

os.loadAPI("drawmon")
logo = paintutils.loadImage("logo")
m = peripheral.wrap("monitor_0")
m.clear()
m.setCursorPos(1,1)
drawmon.drawImage(m, logo, 1, 1)
Edited on 18 March 2015 - 12:36 AM
gametechish #6
Posted 18 March 2015 - 01:47 AM
OMG thank you that works flawlessly you should post that on the forums