Skip to content

Is it possible to get the character at some position in the terminal/monitor? #1886

Answered by fatboychummy
TheSirHunter asked this question in Q&A
Discussion options

You must be logged in to vote

Don't need to modify the window API. It already has this feature.

local win = window.create(term.current(), 1, 1, term.getSize()) -- create a new window the size of the terminal.
local old = term.redirect(win) -- redirect the terminal to this object (so print and etc write to it)

-- write stuff to the screen

-- get the text, text colors, and bg colors of the given line
local text, textColor, bgColor = win.getLine(line_y)

print("char at x,y:", text:sub(x, x))
print("textColor at x,y:", textColor:sub(x,x))
print("bgColor at x,y:", bgColor:sub(x,x))

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@fatboychummy
Comment options

Answer selected by SquidDev
@zyxkad
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants