8 posts
Location
SE Alberta, Canada
Posted 16 October 2012 - 05:29 AM
Is there a way you could go about shutting down the Computer after say, 10 minutes of in-activity?
I know you could add a shell.run() to your startup that shuts it down after X amount of minutes no matter what.
I just would like to know if there is a way to do that, but whenever a button is pressed or something, the timer restarts?So I got this done:
os.pullEvent = function(filter)
local timer = os.startTimer(5)
local evt, p1, p2, p3, p4, p5 = os.pullEventRaw()
if evt == "terminate" then
error("Terminate")
elseif evt == "timer" and p1 == timer then
os.shutdown()
end
timer = os.startTimer(5)
return evt, p1, p2, p3, p4, p5
end
Now how do I run that paralell? Sorry, I do not know much about paralell API=/
Edited on 17 October 2012 - 12:47 AM
1214 posts
Location
The Sammich Kingdom
Posted 16 October 2012 - 06:01 AM
Well just use a timer in the OS API and just cancel the timer if a key is pressed. This is simple code but I highly doubt anybody on here will write it for you. You will also want to use the parallel API to run it the same time as shell.
8 posts
Location
SE Alberta, Canada
Posted 17 October 2012 - 01:52 AM
Alright thanks a ton =)
1214 posts
Location
The Sammich Kingdom
Posted 17 October 2012 - 04:01 AM
Turn your code into a function then do:
local function hello()
shell.run("rom/programs/shell")
end
parallel.waitForAny(hello. yourFunctionNameHere)
That should work.