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

[LUA][Question] Is there a way to "read" a symbol printed on the screen?

Started by ikke009, 25 January 2013 - 07:39 AM
ikke009 #1
Posted 25 January 2013 - 08:39 AM
For instance if I printed the letter A on coördinates (5,5), is there a simple way to make the computer check if there is a symbol there, and if so, return it?
OmegaVest #2
Posted 25 January 2013 - 08:43 AM
Not really.

The simplest thing to do is to make every print or write also write characters to a table. Then, when you want to read the screen, find that position on the table. I think MysticT had an API for it in his OS, I'm still not sure if they have it as a stand-alone. Someone does, though, if you go look through the programs forum. Unless you want to write one for yourself.
ikke009 #3
Posted 25 January 2013 - 09:02 AM
Hmm I don't really want to do it that way.. I guess I'll trade in beauty for efficiancy for my game (for now) :P/> thanks tho
billysback #4
Posted 25 January 2013 - 11:18 AM
I got a buffer API (or screen API) that does exactly this for you, it's use is for something else and is a bit more complex than may be required for your use, but i never released it and would be happy to give it to you if you want.

It is 100% untested, though.
ikke009 #5
Posted 26 January 2013 - 03:36 AM
Thanks, but I only use "vanilla" computercraft stuff for my projects ;)/>
KaoS #6
Posted 26 January 2013 - 04:37 AM
I made a program for that too :)/>

it is in my programs and utilities post. here is the pastebin

basically after running my program use term.getTextAt(x,y,[len]) and it will give you the text at x->x+len;y as well as the text color at x,y and the background color at x,y

EDIT: if you don't want to use anything but your program rather than distributing it in pieces you are welcome to just paste my code in before yours and it will work fine
Edited on 26 January 2013 - 05:41 AM
remiX #7
Posted 26 January 2013 - 06:16 AM
Someone asked this question a while back.

But yes, the only way is to make every print/write save into a file or whatever and then make a function that returns the correct index with the characater(s)