BrastaSauce Posted May 2, 2014 Share Posted May 2, 2014 So, I'm creating an alarm system, and I need help since I'm fairly new to this. So I've already got most stuff down, except the main part, calling the alarm sound when the set time comes. Could someone just give me a few tips on how I would go about this? And please, don't just give me a script that will work, cause I won't learn that way Link to comment
justn Posted May 2, 2014 Share Posted May 2, 2014 You want to play a sound after a certain number of seconds/minutes ? Link to comment
BrastaSauce Posted May 2, 2014 Author Share Posted May 2, 2014 Well, the player sets an alarm in 24 hour time. I want it so when local time (aka getRealTime) reaches that time, it plays a sound. Right now I have it so if the time set = current time, it plays the sound. Just as a test though, and it works flawlessly. Link to comment
justn Posted May 2, 2014 Share Posted May 2, 2014 Well, you'd need to check the hour and minutes to see if it's that time which you're looking for. and if it is. then you'd use playSound to play the sound. Link to comment
BrastaSauce Posted May 2, 2014 Author Share Posted May 2, 2014 I know. But would I continue looping a check to see if it's the set time? Link to comment
'LinKin Posted May 2, 2014 Share Posted May 2, 2014 How about you do something like this: When the player sets the alarm, it does: local time = alarmTime - currentTime and then you use setTimer(yourFunction, time, 1) This would work if the alarm is set further the currentTime AND in the same day. You can just find out how to make it work for alarms set to the next day. Link to comment
BrastaSauce Posted May 2, 2014 Author Share Posted May 2, 2014 How about you do something like this:When the player sets the alarm, it does: local time = alarmTime - currentTime and then you use setTimer(yourFunction, time, 1) This would work if the alarm is set further the currentTime AND in the same day. You can just find out how to make it work for alarms set to the next day. I thought about it, but wouldn't that result in the alarm being slightly off? Possibly even by 50 seconds? Link to comment
'LinKin Posted May 3, 2014 Share Posted May 3, 2014 No. I don't think so. I think setTimer is precise for what you're doing here. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now