- Site Map >
- Modding and Creation >
- Sims 4 Creation >
- Modding Discussion >
- [FIXED] calling function every xx hours issue
- Site Map >
- Modding and Creation >
- Sims 4 Creation >
- Modding Discussion >
- [FIXED] calling function every xx hours issue
Replies: 2 (Who?), Viewed: 488 times.
#1
12th Jul 2015 at 9:34 AM
Last edited by sachamagne : 16th Jul 2015 at 4:17 AM.
Posts: 110
Thanks: 628 in 22 Posts
[FIXED] calling function every xx hours issue
Hi again...I tried to call a function every xx hours and so far it failed. I know the function works and got no errors in logs.
Activating code:
Code:
ts = services.time_service() span = interval_in_sim_hours(1) alarm_hour= ts.sim_now.hour() time=create_date_and_time(hours=alarm_hour) time=ts.sim_timeline.now + span write_debug_log('time={} , span {}'.format(time,span)) AlarmHandle(StartMod, DoJob, ts.sim_timeline,time, repeating=True, repeat_interval=span, accurate_repeat=True)
Debug:
Code:
[07/12/15 10:24:57]<DEBUG>time=02:18:57.280 day:1 week:2 , span 1.00 hours [07/12/15 10:24:57]<DEBUG>next call:02:18:57.280 day:1 week:2
What am i doing wrong ?
Thanks for your explanation !
Advertisement
#2
15th Jul 2015 at 11:48 PM
Posts: 6,939
Thanks: 7556 in 405 Posts
Quote: Originally posted by sachamagne
Hi again... I tried to call a function every xx hours and so far it failed. I know the function works and got no errors in logs. Activating code:
Code:
ts = services.time_service() Debug:
Code:
What am i doing wrong ? Thanks for your explanation ! |
I believe you want to create a global variable to store your alarm handle and then use the sims4.reload.protected member to store the global between game reloads (screen switches). If the handle goes away, so does your alarm and the way you have it defined above, the handle will disappear.
Code:
with sims4.reload.protected(globals()): SCHEDULED_ALARM = None
Code:
global SCHEDULED_ALARM ts = services.time_service() span = interval_in_sim_hours(1) alarm_hour= ts.sim_now.hour() time=create_date_and_time(hours=alarm_hour) time=ts.sim_timeline.now + span write_debug_log('time={} , span {}'.format(time,span)) SCHEDULED_ALARM = AlarmHandle(StartMod, DoJob, ts.sim_timeline,time, repeating=True, repeat_interval=span, accurate_repeat=True)
#3
16th Jul 2015 at 4:17 AM
Posts: 110
Thanks: 628 in 22 Posts
I had a long 'talk' with a guru about that one. Short answers: Don't use AlarmHandle but add_alarm.
I link the thread for reference:
see: http://forums.thesims.com/en_US/dis...ly-alarmhandlde
Thanks all for your answers !
I link the thread for reference:
see: http://forums.thesims.com/en_US/dis...ly-alarmhandlde
Thanks all for your answers !
Who Posted
|