Irregular Thunder

From Seltanikor
Jump to navigationJump to search

To the extent possible under law, the person who associated CC0 with this work has waived all copyright and related or neighboring rights to this work.

This is a script that displays a random message at irregular intervals, Age-wide. (It is a simplified version of the thunder and lightning in Laufensea Pod.

This requires four properties, all at the realm (Age-wide) level.

The idea is that when the instance awakens (when someone links in), a regular timer begins: it will call thundertimer every 20 seconds. (The sched() call runs its first iteration after a 20-second delay. We also call thundertimer immediately, so that the calls happen at 0 seconds, 20 seconds, 40 second, etc.)

thundertimer doesn't display anything itself. It fires another, non-repeating timer with a random delay from 1 to 15 seconds. This ensures that the thunder doesn't happen exactly every 20 seconds. The first noise (cued by the immediate thundertimer call) will be 0-15 seconds after link-in; the second will be 20-35; the third will be 40-55; etc.

Finally, thundertimer2 does the actual work. It chooses a random string (from a list in a property) and displays it realm-wide.

After you set this up, be sure to use the /bootinstance command to kick yourself out of the Age and put it to sleep. The on_wake property will run the next time you link in. You'll also have to /bootinstance if you change the on_wake or thundertimer properties (say, if you're changing the delay values). Once started, the properties run until the instance sleeps, and changing their code while they're running is not generally possible.

on_wake: (Code):

   sched(datetime.timedelta(seconds=20), thundertimer, repeat=True)

thundertimer: (Code):

   sched(datetime.timedelta(seconds=random.randrange(15)+1), thundertimer2)

thundertimer2: (Code):

   eventloc(realm, random.choice(thunderlist))

thunderlist: (Value):

   ['You hear a crash of thunder.', 'Thunder rumbles in the distance.',
    'You hear thunder crashing.',
    'The sky flickers with lightning, followed moments later by rolling thunder.',
    'Lightning illuminates the sky.', 'A double crack of thunder startles you.',
    'A crack of thunder startles you.', 'You hear thunder, very near.']