- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Need help setting alarm to fire at correct time.
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Need help setting alarm to fire at correct time.
Replies: 2 (Who?), Viewed: 4120 times.
#1
8th May 2018 at 9:58 PM
Posts: 52
Need help setting alarm to fire at correct time.
This is the method I am using...I understand most of it, but I am having a hard to being sure exactly what is what...
What I am wanting to do, eventually (not attempted in this method) is have an alarm that goes off every 30 minutes game time, fires *only* 5 times, and then quits.
I understand how to remove the alarm handle (also not included here)
So, the basic question is this...
Within the parameters below, which numbers need adjusting to get the desired fired every 30 minutes but *only* fired 5 times?
I am getting confused between Frequency, Duration, the time unit (5f) in the this.mStopHuntAlarmHandle line and the repeatFrequency (second 5f in same line).
Any help with describing the differences here is greatly appreciated.
Thank you!
public const float kAlarmPeriodInSimMinutes = 1f;
public static float kStopHuntAlarmFrequencyInSimMinutes = 1f;
this.mStopHuntAlarmHandle = AlarmManager.Global.AddAlarmRepeating(5f, TimeUnit.Minutes, new AlarmTimerCallback(this.OnStopHuntAlarm), 5f, TimeUnit.Minutes, "Alarm", AlarmType.AlwaysPersisted, this.Actor);
if (SimClock.ElapsedTime(TimeUnit.Minutes, this.mTimeOfLastStopHunt) >= AmazonHunter.kStopHuntAlarmFrequencyInSimMinutes)
{
this.mTimeOfLastStopHunt = SimClock.Add(this.mTimeOfLastStopHunt, TimeUnit.Minutes, AmazonHunter.kStopHuntAlarmFrequencyInSimMinutes);
Advertisement
#2
9th May 2018 at 2:48 PM
Posts: 3,860
Thanks: 8548 in 67 Posts
It's always easier to check out the original script to understand the overload. In this case it says:
public AlarmHandle AddAlarmRepeating(float time, TimeUnit unitOfTime, AlarmTimerCallback func, float repeatLength, TimeUnit repeatFrequency, string alarmName, AlarmType alarmType, IAlarmOwner objectRef)
if we look here for example:
long val = SimClock.ConvertToTicks(time, unitOfTime);
(The switch for the convertToTicks:
case TimeUnit.Minutes:
result = (long)(time * 37.5f);
break;
)
it basically means that your 5f is 5f * 37.5f the minutes. The other 5f would be a repeat of the same as the other one which is also stated in the script:
Timer t = new Timer(val, func, repeatLength, repeatFrequency, alarmHandle, alarmName, alarmType, objectRef);
It's totally fine to check out this one: // Sims3.Gameplay.Utilities.AlarmManager
I will say floats and such aren't exactly my strongest side, so anyone else, feel free to correct me/help out on that part
public AlarmHandle AddAlarmRepeating(float time, TimeUnit unitOfTime, AlarmTimerCallback func, float repeatLength, TimeUnit repeatFrequency, string alarmName, AlarmType alarmType, IAlarmOwner objectRef)
if we look here for example:
long val = SimClock.ConvertToTicks(time, unitOfTime);
(The switch for the convertToTicks:
case TimeUnit.Minutes:
result = (long)(time * 37.5f);
break;
)
it basically means that your 5f is 5f * 37.5f the minutes. The other 5f would be a repeat of the same as the other one which is also stated in the script:
Timer t = new Timer(val, func, repeatLength, repeatFrequency, alarmHandle, alarmName, alarmType, objectRef);
It's totally fine to check out this one: // Sims3.Gameplay.Utilities.AlarmManager
I will say floats and such aren't exactly my strongest side, so anyone else, feel free to correct me/help out on that part
#3
9th May 2018 at 3:15 PM
Posts: 52
Quote: Originally posted by Lyralei
It's always easier to check out the original script to understand the overload. In this case it says: public AlarmHandle AddAlarmRepeating(float time, TimeUnit unitOfTime, AlarmTimerCallback func, float repeatLength, TimeUnit repeatFrequency, string alarmName, AlarmType alarmType, IAlarmOwner objectRef) if we look here for example: long val = SimClock.ConvertToTicks(time, unitOfTime); (The switch for the convertToTicks: case TimeUnit.Minutes: result = (long)(time * 37.5f); break; ) it basically means that your 5f is 5f * 37.5f the minutes. The other 5f would be a repeat of the same as the other one which is also stated in the script: Timer t = new Timer(val, func, repeatLength, repeatFrequency, alarmHandle, alarmName, alarmType, objectRef); It's totally fine to check out this one: // Sims3.Gameplay.Utilities.AlarmManager I will say floats and such aren't exactly my strongest side, so anyone else, feel free to correct me/help out on that part |
I think you have it correct. i am still confused between repeatLength and repeatFrequency, but I also think that probably studying your description up there will sort it out.
I am close to resolving most of the three questions I have asked in the past few days and I believe I can mark them all Resolved soon.
I have to conduct a bit more testing, though, first to make sure I have a clear understanding because I will also post the methods used.
Honestly, this all has been tremendously helpful. Thank you, to you all!
Who Posted
|