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!
Quick Reply
Search this Thread
Forum Resident
Original Poster
#1 Old 11th Feb 2016 at 5:40 PM
Default Python function that runs on a daily basis?
How would one create a function that runs on a daily basis?
Advertisement
Deceased
#2 Old 12th Feb 2016 at 4:35 PM
I do this in Evict Ghost Households as so, but I haven't even tried checking this for compatibility yet and it's possible the alarm stuff has changed. You could check Deaderpool's command center for a guaranteed up-to-date example I'm sure. This runs every seven days, but altering that should be obvious
Code:
def egh_set_alarm():
    global egh_alarm
    if egh_alarm is not None:
        alarms.cancel_alarm(egh_alarm)
        egh_alarm = None
    time_service = services.time_service()
    time = date_and_time.create_date_and_time(hours=1)
    span = time_service.sim_now.time_till_next_day_time(time)
    time = time_service.sim_timeline.now + span
    span = clock.interval_in_sim_days(7)
    egh_alarm = alarms.AlarmHandle(egh_set_alarm, egh_evict_ghost_families, time_service.sim_timeline, time, repeating=True, repeat_interval = span, accurate_repeat=True)

@injector.inject_to(zone.Zone, 'on_hit_their_marks')
def egh_on_hit_their_marks(original, self):
    original(self)
    egh_set_alarm()
Back to top