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

[1.32] Background Programs

Started by coolblockj, 22 March 2012 - 08:29 PM
coolblockj #1
Posted 22 March 2012 - 09:29 PM
A nice feature would be a program that can be running all the time, this could make things such as keyloggers possible, having a program in the background recording all the keys, but still allowing you to do things.
Liraal #2
Posted 22 March 2012 - 09:31 PM
it's possible, i can write it in no time at all. It's actually being done all the time, as computers run both shell and rednet at the same time.

try reading about parallel API.
PatriotBob #3
Posted 22 March 2012 - 11:42 PM
Well…kinda in parallel…

Best bet is to run your "background" program then create a coroutine of your foreground program (or parallel which ever peels your banana) and have you background program yield(or os.pullEvent) then when ever your background programs resumes from it's yield, pass the event and params on to the foreground program using coroutine.resume(…)

Lua does not support threads or parallel processing outside of multiple interpreters. (for our loss… :(/>/> )
Coroutines are your best bet, but it's little more the well organized task switching.
coolblockj #4
Posted 22 March 2012 - 11:54 PM
Thanks guys, I havn't got much into Coroutines or Parallel API, ill have to look into that.