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

How to run a program on access?

Started by weirdwolf, 27 November 2016 - 12:15 AM
weirdwolf #1
Posted 27 November 2016 - 01:15 AM
Alright, straight to the problem at hand.

I have made myself a password program (protected from Ctrl+T) that i would like to run on access to the computer, say you have a password protected door using a monitor on the side of the computer with a numpad lock, but anyone can right click the computer and change the password to said numpad (i like configurability) is there a way to make my password program run, as soon as the computer itself gets accessed?
Bomb Bloke #2
Posted 27 November 2016 - 01:40 AM
http://www.computercraft.info/wiki/Startup
weirdwolf #3
Posted 27 November 2016 - 01:36 PM
Not quite what i was gunning for, what i'd like is for, when the computer is running a program already, when you then access the computer a password program will run, then if you get the correct password it'll go back to running the other program, and to make sure the first program is 'always' running, it would look for input, and if nothing has been written for a couple of seconds it would terminate and go back to the first program, so a loop of the two programs if you will
Bomb Bloke #4
Posted 28 November 2016 - 12:10 AM
The computer can't tell if a user is sitting in front of it or not.

Is there any particular need to only run one program at a time? It sounds like you could just run your two scripts in different multishell tabs… assuming you couldn't just code all functionality into one script.
weirdwolf #5
Posted 28 November 2016 - 03:44 PM
there isn't a way to check if a player has clicked the computer? like checking where on a monitor a player has right-clicked?
H4X0RZ #6
Posted 28 November 2016 - 09:07 PM
there isn't a way to check if a player has clicked the computer? like checking where on a monitor a player has right-clicked?

Sure, it's possible to get mouse events, but they won't tell the program if a player interacted with the computer or not.
EveryOS #7
Posted 28 November 2016 - 10:19 PM
First, make coroutine manager, or find one online. Also make a timer var On the coroutine manager run your program and rom/programs/shell. Next, create a whitelist with user-events.
Now, rig os.pullEventRaw to check against that list, and if it finds a match, then reset the timerVar. But do this after also rigging it to check timerVar, and if timer var is greater than 180000 than go back to the login screen.
Edited on 28 November 2016 - 09:22 PM
KingofGamesYami #8
Posted 28 November 2016 - 10:24 PM
First, make coroutine manager, or find one online

No. Using the built-in coroutine manager is much better, as it is guaranteed to work properly.
Lupus590 #9
Posted 29 November 2016 - 11:39 AM
First, make coroutine manager, or find one online

No. Using the built-in coroutine manager is much better, as it is guaranteed to work properly.
Might have been useful to have a link: http://www.computercraft.info/wiki/Parallel_(API)
hbomb79 #10
Posted 02 December 2016 - 02:35 AM
First, make coroutine manager, or find one online

No. Using the built-in coroutine manager is much better, as it is guaranteed to work properly.
Might have been useful to have a link: http://www.computerc.../Parallel_(API)

I swear, 90% of the time someone says to make a custom coroutine manager, the built in API is adequate and as mentioned - will work properly.
Lupus590 #11
Posted 02 December 2016 - 11:51 AM
BB's guide to coroutines is overdue here.