Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Test Subject
Original Poster
#1 Old 8th May 2018 at 9:58 PM
Default 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
Virtual gardener
staff: administrator
#2 Old 9th May 2018 at 2:48 PM
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
Test Subject
Original Poster
#3 Old 9th May 2018 at 3:15 PM
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!
Back to top