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

How to run a program on a monitor in the background while startup is running

Started by computercraftrules89, 01 October 2014 - 05:11 AM
computercraftrules89 #1
Posted 01 October 2014 - 07:11 AM
Hi there

Sorry if this has been asked but everything I have looked at so far is too confusing to me and I cant get it to work.

I Have a startup program that I want to run and at the same time I want it to output time to a monitor on the right.

Here's my failing code so far


os.pullEvent = os.pullEventRaw
os.loadAPI("rom/apis/peripheral")
while true do
parallel.waitForAny(Time(), startup() shell.run("shell") end)
end
os.loadAPI("rom/apis/shell")
os.loadAPI("rom/apis/os")
term.clear()
term.setCursorPos(1,1)
print("Sean's PC enter password to get to main menu")
sleep(15)
input = read("*")
if input == "password" then --quoted out as its my computer on my online private server
shell.run("Mainmenu")
else
write("Wrong Password ")
sleep(5)
term.clear()
sleep(5)
write("Restarting ")
sleep(5)
os.reboot()
end
if input == "  " then
write("I don't get what you want ")
os.reboot()
end
Bomb Bloke #2
Posted 01 October 2014 - 07:53 AM
Let's say you have two scripts, and you want to run them side by side. You'd give them different names, then make a startup script just containing this:

parallel.waitForAll(function() shell.run("script1") end, function() shell.run("script2") end)

If you have access to ComputerCraft 1.6 or later, and you're using an advanced system, then you could instead make use of shell.openTab().
computercraftrules89 #3
Posted 01 October 2014 - 08:54 AM
Thanks for the fast reply.

What you said works the only problem is it displays my Time program on the screen and not on the monitor

So if I could have the main program that loads other stuff and in the background have Time running to the monitor.
Bomb Bloke #4
Posted 01 October 2014 - 08:56 AM
If you don't want to code the Time script to output to your monitor, change the shell.run() / shell.openTab() call for it to something like:

shell.run("monitor top timeScript")
computercraftrules89 #5
Posted 01 October 2014 - 10:02 AM
Yeah cant get the time to display on the monitor while doing other stuff.

Thanks for the help though.
Dragon53535 #6
Posted 01 October 2014 - 10:03 PM
Your monitor is on the right, you would need

shell.run("monitor right timeScript")