Posted 20 May 2017 - 11:44 AM
I'm trying to figure out how I can run 2 different programs within the same shell using 2 different windows.
So my first approach was to do:
However this fails to work unless all outputting I do is through term (for example when I call print). I then tried to wrap term.current and force it to return termA if the first script called it and termB if the second one did:
But that didn't work. Is there a way to do what I want? I don't know much about the CC API so if this is obvious I'm sorry :P/>.
So my first approach was to do:
local sX, sY = term.getSize()
local fileA, fileB = "blah", "blah blah"
local termA = window.create(term.current(), 1, 1, sX, sY/2)
local termB = window.create(term.current(), 1, sY/2+1, sX, sY/2)
parallel.waitForAny(
function() os.run({ term = termA }, fileA) end,
function() os.run({ term = termB }, fileB) end
)
However this fails to work unless all outputting I do is through term (for example when I call print). I then tried to wrap term.current and force it to return termA if the first script called it and termB if the second one did:
local envA = { term = termA }
local envB = { term = termB }
local _current = term.current
function term.current()
local env = getfenv(2)
if env == envA then
return termA
elseif env == envB then
return termB
else
return _current()
end
end
But that didn't work. Is there a way to do what I want? I don't know much about the CC API so if this is obvious I'm sorry :P/>.