Jump to content




How Can You Get Whats On The Screen


  • You cannot reply to this topic
7 replies to this topic

#1 jay5476

  • Members
  • 289 posts

Posted 10 August 2013 - 03:08 AM

hello, im wondering how to get all the text that's on the screen like in the screen capture programs made, I have tried looking through the code but found nothing

#2 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

Posted 10 August 2013 - 10:21 AM

Well in order to do this you'll have to use function overriding. Function overriding is where you take a function, save it in a variable, and then override the old function with a new one.

In order to get all the text on the screen, you'll have to override term.write with your own function that somehow saves the information. Here's my example:
oldWrite = term.write --# First off we need to save term.write in a variable so we can still use it

storage = {} --# Here is where we can keep everything written to the screen

term.write = function(input) --# Now we're overriding the old variable
  table.insert(storage, input) --# Now we're saving the input to storage
  oldWrite(input) --# And go ahead and use the old function to actually write to the screen
end

If you run the above program, you will begin capturing all text input in the storage table. In order to see the information, you can go into the lua prompt and type "table.concat(storage,',')". This will take all of the stuff in the storage table and write it to the screen, separating each element with a comma.

#3 jay5476

  • Members
  • 289 posts

Posted 10 August 2013 - 04:07 PM

do I do the same with print ?

#4 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

Posted 10 August 2013 - 05:34 PM

View Postjay5476, on 10 August 2013 - 04:07 PM, said:

do I do the same with print ?

Nope. Print uses term.write.

#5 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 10 August 2013 - 07:48 PM

Of course, this won't tell you where on the screen it is, or when it was put on the screen, or if the screen was cleared or scrolled. To get all of that information, you'd want to create a redirect table with functions that record all of the term calls.

#6 jay5476

  • Members
  • 289 posts

Posted 11 August 2013 - 05:16 AM

okay im using a code and it is completely bugging out(some startup:5parallel:22), code can be found here: pastebin.com/cr3k9uru

#7 CometWolf

  • Members
  • 1,283 posts

Posted 11 August 2013 - 05:25 AM

your table insert is in the wrong order. It should be (table, insertobject)
w = term.write
stor = {}
term.write = function(inp)
  table.insert(stor, inp)
  w(inp)
end


#8 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 11 August 2013 - 07:21 AM

How screen capture programs work is by replacing all the term functions, so anything that writes to the screen calls their functions instead.
Then they record it in a file, and also call the real term functions (so you can see what you're doing).
All screen access eventually calls a term function, even print and write.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users