How To Make Some Kind Of A Notifcation
Started by theeboris, Oct 04 2013 08:53 AM
9 replies to this topic
#1
Posted 04 October 2013 - 08:53 AM
Hello,
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
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
#2
Posted 04 October 2013 - 10:23 AM
Lemme make sure I got this right...you want to run a block of code within another code, and when the new code block is run, you want to return to where you were?
What you want to do is run a redraw function to return you to where you were when you originally ran that first code.
What you want to do is run a redraw function to return you to where you were when you originally ran that first code.
#3
Posted 04 October 2013 - 11:17 AM
Yes
Exactly that
Do you know how I can do that?
#4
Posted 04 October 2013 - 07:41 PM
In startup, you could override the shell.run function to call term.restore before returning.
#5
Posted 04 October 2013 - 08:35 PM
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.
I think that either term.restore doesn't do what you think it does, or you're not understanding the OP's question.
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? ' )
Yevano, on 04 October 2013 - 07:41 PM, said:
In startup, you could override the shell.run function to call term.restore before returning.
#6
Posted 04 October 2013 - 08:57 PM
theoriginalbit, on 04 October 2013 - 08:35 PM, said:
I think that either term.restore doesn't do what you think it does, or you're not understanding the OP's question.
Yeah, I think I was half answering his question and half answering someone else's question from another thread.
#7
Posted 04 October 2013 - 09:06 PM
Yevano, on 04 October 2013 - 08:57 PM, said:
Overriding 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
done, then you just go
runProgram( "monitor", "left", "edit", "startup")
No override needed.
#8
Posted 05 October 2013 - 06:56 AM
theoriginalbit, on 04 October 2013 - 08:35 PM, said:
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. I think that either term.restore doesn't do what you think it does, or you're not understanding the OP's question.
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? ' )
Yevano, on 04 October 2013 - 07:41 PM, said:
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?
#9
Posted 05 October 2013 - 09:29 AM
theeboris, on 05 October 2013 - 06:56 AM, said:
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?
As in, have a virtual screen in a specific area of the real monitor? Yeah, you could use Gopher's API. If you want to make it yourself, it would just require some overrides of the term functions, I think.
#10
Posted 05 October 2013 - 10:22 AM
I'm going to test it
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











