Forum Discussion
SimGuruEugi
EA Staff (Retired)
11 years agoYou can use the syntax to properly format code with indentation.
The example you have provided does not hold a strong reference to your handle. Also, you need a strong reference to the alarm owner, which is the first argument to the add_alarm function.
Compare these two snippets:
The example you have provided does not hold a strong reference to your handle. Also, you need a strong reference to the alarm owner, which is the first argument to the add_alarm function.
Compare these two snippets:
def _setup_alarm():
def _callback(handle):
pass
alarm_handle = alarms.add_alarm(_setup_alarm, clock.interval_in_sim_minutes(10), _callback)
# Once this function returns, alarm_handle is garbage
# collected because there are no strong references to it.
alarm_handle = None
def _setup_alarm(self):
def _callback(handle):
pass
global alarm_handle
alarm_handle = alarms.add_alarm(_setup_alarm, clock.interval_in_sim_minutes(10), _callback)
# Once this function returns, alarm_handle is still strongly
# referenced. Your alarm will survive.
About The Sims 4 Mods & Custom Content
Find expert tips, troubleshooting help, tutorials for mods and custom content, and The Sims 4 patch files in our forum.15,684 PostsLatest Activity: 2 hours ago
Community Highlights
Recent Discussions
- 3 hours ago