Jump to content




Running a program for a certain amount of time?

lua

  • You cannot reply to this topic
4 replies to this topic

#1 lieudusty

  • Members
  • 419 posts

Posted 17 August 2012 - 03:08 PM

Hi everyone! =D

This is probably a noob question but how do I make a program run for a certain amount of time then stop? Thanks.

#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 17 August 2012 - 03:13 PM

It depends on the program running. Some cases you can just have it sleep for a certain amount of time, and os.shutdown(), other times you would need to use some timers and os.pullEvent()... What kind of program are you running? Could you post the code?

#3 lieudusty

  • Members
  • 419 posts

Posted 17 August 2012 - 03:23 PM

Well I wanted to continuously print something for lets say 10 seconds then stop.

#4 ardera

  • Members
  • 503 posts
  • LocationGermany

Posted 17 August 2012 - 03:34 PM

Code:
function a()
  shell.run("theprogram")
end
function b()
  sleep(10)
end
parallel.waitForAny(a, :(/>/>
(This is a program to run the program "theprogram" for 10 secs)

#5 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 17 August 2012 - 03:37 PM

View Postardera, on 17 August 2012 - 03:34 PM, said:

Code:
function a()
  shell.run("theprogram")
end
function b()
  sleep(10)
end
parallel.waitForAny(a, :(/>/> --your code here called for "B", and we needed "b"
(This is a program to run the program "theprogram" for 10 secs)

Slight correction.





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users