Redpulse Without Computer Sleeping
#1
Posted 05 March 2013 - 04:39 AM
shell.run (redpulse, "right", 1, 20)
It will send the pulse for 20 seconds but not freeze up the computer. I looked into the redpulse file but it really looks like it the way it works is off of redset which works solely on true and false. In which case removing any sleep timers would just break the entire pulse to begin with. Any thoughts would be much appreciated!
#2
Posted 05 March 2013 - 04:48 AM
#3
Posted 05 March 2013 - 04:48 AM
This api basically allows you to run multiple functions simultaneously, allowing users to have a great advantage for functions.
PS, using the shell.run you need quotes around everything
shell.run("redpulse right 1 20")
#4
Posted 05 March 2013 - 04:50 AM
#5
Posted 05 March 2013 - 04:56 AM
function pulse() -- code for pulse here end function otherStuff() --other stuff here end parallel.waitForAll(otherStuff,pulse)
it will wait until both function have finished and returned a value
just make sure there wont be long codefragments that dont yield (if you are unsure about that, just use os.sleep(0.1) every now and then)
Also you can use parallel.waitForAny(), which breaks the program when one function finishes
#6
Posted 05 March 2013 - 09:11 AM
#7
Posted 05 March 2013 - 11:26 AM
#8
Posted 06 March 2013 - 01:17 AM
#9
Posted 06 March 2013 - 08:57 AM
boudragon, on 05 March 2013 - 09:11 AM, said:
#10
Posted 06 March 2013 - 09:46 AM
All sleep actually does is set a timer and block all else until the timer expires.
If the program you're trying to use handles events, make the computer set a timer when the pulse starts and make the program you're using shut off the pulse when it detects that timer's event.
#11
Posted 06 March 2013 - 11:10 AM
#12
Posted 06 March 2013 - 11:22 AM
boudragon, on 06 March 2013 - 11:10 AM, said:
#13
Posted 06 March 2013 - 01:27 PM
#14
Posted 06 March 2013 - 03:20 PM
Make a table in global to store 'system events' (events queued to happen at a certain time).
Make the login screen wait for events
(it probably already waits for keypresses, ,unless you're using the built in read() system, in which case, change it asap)
When a timer/alarm fires, make it check the 'system events' to check how to react to that event
(ie use the timer/alarm table returned by the start timer/ set alarm as the key for the value in the table)
In your door open/close program, make it set an alarm/timer as a system event (ie systemevents[os.startTimer(10)]="closedoor")
then make it logout
when the alarm goes off, the login screen will know to check system events to see if one matches the returned timer ref,
if it works correctly, the login screen should know to close the door.
I recommend making system events either store a function to call or a string to run dostring on, since it gives you more adaptability than just set commands.
Not exactly a simple way to do things, but then again interrupting the natural flow of events isn't really a novice thing.
Of course since sleeping stops the computer getting input, you could just make the system logout before calling sleep, then close the door when sleep is up. It would be a lot simpler, just not as realistic. Then again, nobody uses computers to open doors in the real world, so hey-ho.
#15
Posted 07 March 2013 - 03:10 AM
#16
Posted 07 March 2013 - 10:41 AM
boudragon, on 07 March 2013 - 03:10 AM, said:
Just stick with my last point. Assuming you have a logoff function:
OpenDoor()--Do redstone stuff to open door LogOff()--Log Out of the computer Wait(10)--Wait some time CloseDoor()--Do redstone stuff to close door GoToLogin()--Return to login screen
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











