Jump to content




How To Make Some Kind Of A Notifcation


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

#1 theeboris

  • Members
  • 59 posts
  • LocationThe Nethelands

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

#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

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.

#3 theeboris

  • Members
  • 59 posts
  • LocationThe Nethelands

Posted 04 October 2013 - 11:17 AM

Yes :D Exactly that :D Do you know how I can do that? :)

#4 Yevano

  • Members
  • 376 posts
  • LocationUSA

Posted 04 October 2013 - 07:41 PM

In startup, you could override the shell.run function to call term.restore before returning.

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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.
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? ' )

View PostYevano, on 04 October 2013 - 07:41 PM, said:

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.

#6 Yevano

  • Members
  • 376 posts
  • LocationUSA

Posted 04 October 2013 - 08:57 PM

View Posttheoriginalbit, 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. :P The part about overriding shell.run, however, is still relevant, even if probably unnecessary for what OP is trying to do. 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. You'd have to also override the term.write function to keep up with the draw buffer so that it can be saved and restored later (after shell.run exits).

#7 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 04 October 2013 - 09:06 PM

View PostYevano, 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.
Not really. look

local function runProgram( path, ... )
  shell.run(path, ...)
  redraw()
end

done, then you just go

runProgram( "monitor", "left", "edit", "startup")

No override needed.

#8 theeboris

  • Members
  • 59 posts
  • LocationThe Nethelands

Posted 05 October 2013 - 06:56 AM

View Posttheoriginalbit, 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.
 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? ' ) 

View PostYevano, on 04 October 2013 - 07:41 PM, said:

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.

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 Yevano

  • Members
  • 376 posts
  • LocationUSA

Posted 05 October 2013 - 09:29 AM

View Posttheeboris, 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 theeboris

  • Members
  • 59 posts
  • LocationThe Nethelands

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