7 posts
Posted 09 August 2013 - 07:30 AM
Hi, Im using a script, that when you touch the monitor(anywhere) it switch to another program. Tho the problem is that first i just used a code so it starts the other program, shell.run… but that messed it up becuase 2 programs was running on the monitor at the same time. So i want a program that when you press then monitor it turns off the first program, and then starts the other program. Now i have it setup so when you press the screen, It renames startup and then reboots the pc, and this close the first program and starts the other this way, It works but it take like 5 sec, i would want it to be much fast, Hope you guys understand what i mean.
P.S it's a screen saver, This is my first program so idk it might be pretty bad. Atm I'm using Redstone signal to send a pulse that's says to the other program that it's being used. Going to change that to write a line to a file
Thanks in advance!
http://pastebin.com/KJEjDp7R (screensaver) only changed some lines at the bottom, not my script
http://pastebin.com/JUBj5CwM (detects if you use the pc)
http://pastebin.com/EidCiyUu (timer)
[[[shell.run("www")]]] (startup)
[[[shell.run("monitor top fire")]]] (startup1)
[[[parallel.waitForAny(function() return shell.run("ss") end, function() return shell.run("ss1") end, function() return shell.run("darkbuttons") end)]]] (www)
these 3 are files but felt kinda waste to upload to pastebin when only 1 line code
112 posts
Posted 09 August 2013 - 12:42 PM
Why not putting those two progs into two functions and then call tbem inside one mainprog …???
7 posts
Posted 09 August 2013 - 02:11 PM
I tried that first but the main program is not made by me. And i didn't know how it worked so i didn't know where to put the functions :/
83 posts
Location
Behind you
Posted 10 August 2013 - 12:36 AM
I don't have much experience with the function but I would suggest you try
shell.exit()
Which I'm told exits the current program running.
515 posts
Location
Australia
Posted 10 August 2013 - 01:56 AM
I don't have much experience with the function but I would suggest you try
shell.exit()
Which I'm told exits the current program running.
Shell.exit doesn't exist. Just use
error()
Don't worry it won't print out that re error code stuff
8 posts
Posted 10 August 2013 - 04:48 AM
Step 1. Wrap the peripheral with
m = peripheral.wrap("SIDE")
(replace SIDE with the side of the monitor)
Step 2. Clear the screen with
m.clear()
Step 3. Run your program
What this does is clears the screen before running your program so that the two programs don't overlap
If I'm right then your problem is the screen keeping the stuff on it when it launches the next program
83 posts
Location
Behind you
Posted 10 August 2013 - 06:04 AM
I don't have much experience with the function but I would suggest you try
shell.exit()
Which I'm told exits the current program running.
Shell.exit doesn't exist. Just use
error()
http://computercraft...wiki/Shell.exitThat is all I have to say.
julllleee, shell.exit() does exist in CraftOS 1.5 (at the very least)
If you don't believe me type "shell.exit" into lua and it should return the function itself, proving it exists.
7 posts
Posted 10 August 2013 - 06:48 AM
Hmm okay i'll look into it :)/> Thanks =)
7 posts
Posted 10 August 2013 - 07:04 AM
I tried to add error and exit code. i changed it to be
"
elseif e[1]=="monitor_touch" then
shell.run("darkbuttons")
shell.exit() OR error()
"
then it starts the darkbuttons program but it don't exit the program? It just freeze, then if i do ctrl+t it shuts down 2 programs. So the fire is running in the background but i can't turn it off :(/>
Is there any way to do like shell.exit(programname)? becuase then i could add to the program thats detect if there is a touch and make that turn off programs?
edit :
Hmm this might work, that you add a line to the programs that if this file exist exit, and then another script thats detect like if the same file exists, sleep 2 sec, starts the other program, deletes the file? i think i could add this.
tho the problem is that i don't understand how the darkbuttons script works. So i don't know where i could possible add this line :(/>
edit 2: looked into this , and can i add a function to this
parallel.waitForAll(hitListen, breakListen, terminalMenu, stealthUpdate)
that is like
function screen()
if fs.exists("touch22") == true then
file = fs.open("screen", "w")
file.close()
sleep(1/4)
fs.delete("screen")
error()
end
and then another program that checks if screen exists and starts the screensaver?
Edited on 10 August 2013 - 05:34 AM