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

A way to get the color of a pixel?

Started by SGunner2014, 03 October 2014 - 04:46 PM
SGunner2014 #1
Posted 03 October 2014 - 06:46 PM
Hey there,

I was wondering if there was a way to get the specific color of a pixel on the screen?
If there is, how would I go about using it?

Thanks,
- Sam
wieselkatze #2
Posted 03 October 2014 - 06:50 PM
Unless you write a utility that saves the background/text color in some way, each time you call term.write(), there is no way to do that, no.
SGunner2014 #3
Posted 03 October 2014 - 06:57 PM
Unless you write a utility that saves the background/text color in some way, each time you call term.write(), there is no way to do that, no.

I am drawing pixels using paintutils.drawPixel()
Does this change anything?

Thanks,
- Sam
Hiran #4
Posted 03 October 2014 - 07:03 PM

function drawPixel( xPos, yPos, nColour )
    if type( xPos ) ~= "number" or type( yPos ) ~= "number" or type( nColour ) ~= "number" then
	    error( "Expected x, y, colour", 2 )
    end
    term.setBackgroundColor( nColour )
    drawPixelInternal( xPos, yPos )
end
local function drawPixelInternal( xPos, yPos )
    term.setCursorPos(xPos, yPos)
    term.write(" ")
end
As you see you cant, but you can create table that will have everything saved. and print stuff from that table
SGunner2014 #5
Posted 03 October 2014 - 08:18 PM
Okay, thanks. I'm going to store the whole thing in a table, and when it is needed to be saved, save all of the stuff in the table and there! Saved!

Many thanks,
- Sam