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

monitor to PDA redirect

Started by Hiran, 02 October 2014 - 09:14 AM
Hiran #1
Posted 02 October 2014 - 11:14 AM
At the beginning some explanation.
PDA screen is 26 x 20 in size, and its similar to 3 x 3 monitor. But if i wanted to redirect content of the larger monitor to my PDA something will just disappear. To get around this i've created this program:

http://pastebin.com/ZZn2zSw6
Just run it, right click and drag and the "haha" will move. Your middle button will reset it to starting position.

But how do i actually redirect content of the monitor to my PDA? The best way would be to create on the monitor window using window API that is equal in size, write some stuff on it, and then send whole window via rednet every time something on the main monitor updates. Rednet has send() and string has serialize(), but will it work as intended? And if something like that would be possible, wouldnt it be cpu-heavy?

Edit:
Is it possible to detect when player opens and closes computer/ PDA? With this i could send messages only when someone "listens".

And do you know any good Satellite api/program?

Edit 2:
Is it somehow possible to read whats written on the monitor?
Would it be better to send rarer (only while window updates) whole window content or more often (especially while dragging) only the data that can be written by the PDA?
Edited on 02 October 2014 - 12:24 PM
Bomb Bloke #2
Posted 02 October 2014 - 02:57 PM
But how do i actually redirect content of the monitor to my PDA? The best way would be to create on the monitor window using window API that is equal in size, write some stuff on it, and then send whole window via rednet every time something on the main monitor updates. Rednet has send() and string has serialize(), but will it work as intended? And if something like that would be possible, wouldnt it be cpu-heavy?

Not possible, sorry, if only because of the data in a "window" object - that includes functions, and also includes a variable pointing to the original "parent terminal" (which won't be available to the PDA).

You could, however, create a custom version of the window API that exposes a table (containing just the displayed data, not all the functions etc) which could be sent via rednet. You'd want a decent understanding of the underlying systems, though.

Is it possible to detect when player opens and closes computer/ PDA? With this i could send messages only when someone "listens".

Sorry, it's not. You can pick up on various interactions with the PDA, but not observation.

And do you know any good Satellite api/program?

You might need to elaborate on what you want with this one.

Is it somehow possible to read whats written on the monitor?

No, though if it was recorded elsewhere at the time it was written, then you could potentially get the data from that other buffer.

(The window API is a buffer, but is rigged to prevent you reading from it. But again, you could make a modified version exposing that data…)

Would it be better to send rarer (only while window updates) whole window content or more often (especially while dragging) only the data that can be written by the PDA?

You'd probably want to rig things so that you could send both partial and complete copies of what's in your buffer. In this way, newly connecting clients can get a copy of the whole screen, then while they remain connected, they'd only require smaller, faster updates as to which parts are changing.

Edit:

In regards to the "can't detect observation" thing - think about how a "real" computer handles that, and how most operating systems decide to stop updating the display with whatever they'd usually show.
Edited on 02 October 2014 - 01:20 PM
Hiran #3
Posted 02 October 2014 - 03:59 PM
Im fairly good with programming so I'll have to analyze window and term APIs, probably something else too, if needed.
And about observation & forced shutdown, ill probably have to use multishell & parallel api to fit my needs. and some sort of timer event.

And it looks like ill have to write my own version of window API xD
Lyqyd #4
Posted 02 October 2014 - 04:01 PM
Looking at my nsh program and framebuffer API may answer a lot of your questions, if you dig into them enough to really get a handle on what they're doing internally. It'll answer a lot of questions about sending the screen via rednet (see also: Terminal Redirection over Rednet, or TRoR) as well as how to actually collect and make use of screen content buffers.