A few days ago I've got an idea. The idea is that I can run some code and write some things on the screen snd if the code is on the end the old screen restores. But I really don't know how to do that. Can anybody help me please?
~TheeBoris
local function redraw( extra )
term.clear()
term.setCursorPos(1,1)
print("My awesome program")
write("What is your poison? "..extra)
end
--# your program contents here
redraw()
local poison = read()
--# run the new program or call a function, or whatever
shell.run("poison", poison)
--# call the redraw, making it look back to where it was, maybe with some extra content too
redraw( poison..'\nHow did that feel? ' )
I think that either term.restore doesn't do what you think it does, or you're not understanding the OP's question.In startup, you could override the shell.run function to call term.restore before returning.
I think that either term.restore doesn't do what you think it does, or you're not understanding the OP's question.
Not really. lookOverriding would be useful if you wanted to do this in all instances, so that for example the shell wouldn't be cleared when you exit a program.
local function runProgram( path, ... )
shell.run(path, ...)
redraw()
end
runProgram( "monitor", "left", "edit", "startup")
theeboris, when you run something such as a program with shell.run/os.run or even a function your program will return to that call and continue running, as such you can (as Cranium stated) create a redraw function which handles setting the screen back to your program's output.local function redraw( extra ) term.clear() term.setCursorPos(1,1) print("My awesome program") write("What is your poison? "..extra) end --# your program contents here redraw() local poison = read() --# run the new program or call a function, or whatever shell.run("poison", poison) --# call the redraw, making it look back to where it was, maybe with some extra content too redraw( poison..'\nHow did that feel? ' )
I think that either term.restore doesn't do what you think it does, or you're not understanding the OP's question.In startup, you could override the shell.run function to call term.restore before returning.
But if I do that I can't make a 'popup'if you know what I mean. Is it a possibility to redirect the screen to a virtual screen?