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

scan screen

Started by Crowdy199, 26 February 2013 - 09:09 AM
Crowdy199 #1
Posted 26 February 2013 - 10:09 AM
is there a way to say scan the screen and if line 4 says this then
CastleMan2000 #2
Posted 26 February 2013 - 10:11 AM
Two things: No, and this is the wrong section. This should be in Ask a Pro.
ikke009 #3
Posted 27 February 2013 - 03:16 AM
it is possible if you store everything that is being printed in a table. Then you can look into that table what is being written where. It can be done for each character on every coordinate, or for each line. Just be creative with it, if you cant get it to work, there are some API's out there that make this possible for you
Mailmanq! #4
Posted 27 February 2013 - 08:53 AM

screen = {}
w, h = term.getSize()
for i = 1, w do
    screen[i] = {}
end

oldWrite = term.write
function term.write(s)
    s = string.gmatch(s, ".")
    local x, y = term.getCursorPos()
    for i = 0, #s-1 do
	    screen[x+i][y] = s[i+1]
    end
end
function print(s)
    term.write(s)
    x, y = term.getCursorPos()
    term.setCursorPos(1, y+1)
end

That should record the whole screen to a table, to see the character at x,y do screen[x][y]