This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
to find out how to get informations about a pixel
Started by Jummit, 05 August 2017 - 10:10 AMPosted 05 August 2017 - 12:10 PM
I am searching for a function to get the background color, the text color and the string which is on the pixel. Is there a function that does this? In the paintutils api is nothing…
Edited on 05 August 2017 - 10:11 AM
Posted 05 August 2017 - 06:19 PM
It is not possible to know what is displayed without recording that information when it is drawn.
Posted 05 August 2017 - 06:28 PM
I'm not sure when it was added, but IIRC CC 1.79 (and possibly earlier?) have term.getTextColor(x, y) and term.getBackgroundColor(x, y) but no way to find out which character is on screen. As KingofGamesYami said, you'll need to record what's written to screen (when it's drawn) if you want to know what characters are where on screen.
EDIT: Correction - as noted below, getTextColor and getBackgroundColor don't use x,y coords.
EDIT: Correction - as noted below, getTextColor and getBackgroundColor don't use x,y coords.
Edited on 05 August 2017 - 11:17 PM
Posted 05 August 2017 - 06:34 PM
Thanks for the information, guys! Would be very usefull to have a a function for this, like term.getPixelInformation or would it be paintutils.getPixelInformation?
Posted 05 August 2017 - 09:06 PM
If it did exist, it would be in the term API.
Posted 05 August 2017 - 09:07 PM
I'm not sure when it was added, but IIRC CC 1.79 (and possibly earlier?) have term.getTextColor(x, y) and term.getBackgroundColor(x, y) but no way to find out which character is on screen.
Added in 1.74, doesn't take an screen coordinate as an argument, gives the current colour (the one most resently set with the equivulent set function). [source - the wiki]
Posted 06 August 2017 - 12:20 AM
I'm not sure when it was added, but IIRC CC 1.79 (and possibly earlier?) have term.getTextColor(x, y) and term.getBackgroundColor(x, y) but no way to find out which character is on screen.
Added in 1.74, doesn't take an screen coordinate as an argument, gives the current colour (the one most resently set with the equivulent set function). [source - the wiki]
Ahh, that makes sense. Thanks, Lupus :)/>
Posted 06 August 2017 - 08:09 PM
@OP It can be done if it's supported by the screen buffer that you are using.
I would use Lyqyd's Framebuffer, but I'm a bit bias to his stuff. You should be able to read the text from the buffer like so, fair warning I haven't tested this
I would use Lyqyd's Framebuffer, but I'm a bit bias to his stuff. You should be able to read the text from the buffer like so, fair warning I haven't tested this
local buf = framebuffer.new(sizeX, sizeY, colour, offsetX, offsetY)
--# you may want to write more stuff to the buffer here
buf.write("this is an example")
buf.buffer.text[x][y] --# should give you the character at that coorodinate
buf.buffer.textColor[x][y] --# same again for the text colour (British spelling for the win)
buf.buffer.backColor[x][y] --# I would help that you would be able to figure this one out