@@ ========================================================================
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@ ------------------------------------------------------------------------
@@ WARPED ~~~~~~~~~~~~~~~~ ~
@@ ~~~~~~~~~ ~~~~~~~~~ WARPEDcore ~~
@@ ~~~~~~ ~~~~~~ ~cron ~~~
@@ ~~~~ Adoption ~~~~ 200601110b ~~~~
@@ ~~~ Date ~~~~~~ ~~~~~~
@@ ~~ 2007.01.11 ~~~~~~~~~ ~~~~~~~~~
@@ ~ ~~~~~~~~~~~~~~~~ core
@@ ------------------------------------------------------------------------
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@ ========================================================================
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@
@@ LEGAL
@@
@@ This material is released under the terms of the
@@ WARPEDcore Softcode and Documentation License (WSDL).
@@ For details, see: http://community.pennmush.org
@@
@@ USE AT YOUR OWN RISK.
@@
@@ Copyright 2007, The WARPEDcore Project
@@
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@
@@ SYSTEM REQUIREMENTS
@@
@@ * PennMUSH version 1.7.4p21 or newer.
@@
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@
@@ The 'cut' line.
@@
@@ It is safe to remove everything above the following line, before quoting
@@ this script into your MUSH.
@@
@@ ========================================================================
@@ . . . . C . . . u . . . t . . . . . . H . . . e . . . r . . . e . . . .
@@ ========================================================================
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@ ------------------------------------------------------------------------
@@
@@ create ~cron
@@
@create ~cron
@set ~cron=NO_COMMAND
@describe ~cron=WARPEDcore~cron
@@
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@
@@ legal reference and version
@@
&~`legal ~cron=http://community.pennmush.org
@@
&~`version ~cron=200701110b
@@
@@ ========================================================================
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@ ------------------------------------------------------------------------
@@
@@ data
@@
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@
@@ variables: configurable.
@@
@@ documentation is provided.
@@
&CONF`INTERVAL ~cron=300
&NOTE`CONF`INTERVAL ~cron=This value represents the frequency of emits in a number of SECONDS. Note, setting this to anything other than an appropriate multiple of sixty (60) will have very screwy results. Recommended values are the following: 60 300 600 900 1200 1800 3600 (1m 5m 10m 15m 20m 30m and 60m, respectively). Default: 300 (5m)
@@
@@ ========================================================================
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@ ------------------------------------------------------------------------
@@
@@ the code.
@@
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@
@@ the loop.
@@
@@ fix this so that the emit is caculated before the final wait length.
@@
@STARTUP ~cron=@wait/until [cemit(~, if(gt(sub(secs(),convtime(starttime())),10),Re-)Started., 1)][setr(s, mul(setr(i, v(CONF`INTERVAL)), inc(div(secs(), %qi))))]=@tr me/TRIG`CRON`LOOP=%qs
@@
&NOTE`STARTUP ~cron=triggers TRIG.CRON.LOOP to start the cron
@@
@@
&TRIG`CRON`LOOP ~cron=@wait/until [cemit(~, ufun(UFUN`CEMIT,%0), 1)][setr(s, mul(setr(i, v(CONF`INTERVAL)), inc(div(secs(), %qi))))]=@tr me/TRIG`CRON`LOOP=%qs
@@
&NOTE`TRIG`CRON`LOOP ~cron=this cemits cron message and reinitiates loop.
@@
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@
@@ the functions
@@
&UFUN`CEMIT ~cron=[u(UFUN`TZ)][@@(UFUN`TZ sets and returns %qz - the timezone offset based on system configuration)]~%0~[u(UFUN`ETIMESTRING, %0)][@@(UFUN`ETIMESTRING sets and returns %qt - the enhanced time string value for %0)][if(hasattrval(me/UFUN`IC),~[u(UFUN`IC, %0)])][@@(does whatever you write UFUN`IC to do)]
@@
&NOTE`UFUN`CEMIT ~cron=this calculates, arranges, and returns the message for the cron cemit, using the subsequent UFUN.* attribs. %0 is the secs() value of the current emit sent to all subsequent functions.
@@
@@
&UFUN`TZ ~cron=[setr(z, div(sub(secs(), convtime(utctime())), 3600))]
@@
&NOTE`UFUN`TZ ~cron=determines sets %qz to the timezone offset in hours, based on your system's configuration.
@@
@@
&UFUN`ETIMESTRING ~cron=[setq(t, convsecs(%0))][inc(div(dec(elements(%qt, 3)), 7))][@@(<-- this calculates N for 'Nth <Weekday> of the month')][if(not(strmatch(elements(%qt, 2), elements(convsecs(add(%0, lmath(mul,60 60 24 7))), 2))), .0)][@@(<-- this appends '.0' to the previously calculated 'N' if and only if this is also the 'last <Weekday> of the month')] %qt
@@
&NOTE`UFUN`ETIMESTRING ~cron=sets %qt to the timestring value for %0 and emits %qt preceded by the <N[.0]> enhancement.
@@
@@
&UFUN`IC ~cron=
@@
&NOTE`UFUN`IC ~cron=write this for your IC cron data. it is sent %qs - the UTSECS value of current emit .
@@
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@
@@ create the cron broadcast channel and configure its locks on the ~cron.
@@
@chan/add ~=object player quiet
@@
@dolist join speak see hide mod=@clock/## ~=@[num(~cron)]
@dolist Join Speak See Hide Mod=@lock/user:Chan##Lock ~cron=LOCK`CHAN`[ucstr(##)]/1
@@
@@
&LOCK`CHAN`JOIN ~cron=cor(orflags(owner(%#), Wr), not(t(member(iter(cwho(~), owner(%i0)), owner(%#)))), u(LOCK`CHAN`JOIN.CUSTOM))
@@
&NOTE`LOCK`CHAN`JOIN ~cron=join-locks the channel to wizards and royalty, mortal players who don't already have an object on channel, and whatever you write in LOCK`CHAN`JOIN.CUSTOM
@@
&LOCK`CHAN`JOIN.CUSTOM ~cron=0
@@
&NOTE`LOCK`CHAN`JOIN.CUSTOM ~cron=write your own truth value test here.
@@
@@
&LOCK`CHAN`SPEAK ~cron=strmatch(%#, num(me))
@@
@@
&LOCK`CHAN`SEE ~cron=1
@@
@@
&LOCK`CHAN`HIDE ~cron=strmatch(%#, num(me))
@@
@@
&LOCK`CHAN`MOD ~cron=0
@@
@@
@chan/on ~=~cron
@@
@@ ========================================================================
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@ ------------------------------------------------------------------------
@@
@@ Help
@@
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@
@@ Help files
@@
&HELP`CRON ~cron=%r<~> <TZ>~<SECS>~<ETIMESTRING>~<IC>%r%r [ljust(<~>,12)] this is the channel name.%r [ljust(<TZ>,10)] TimeZone offset in hours>%r [ljust(<SECS>,12)] secs() of the current emit%r [ljust(<ETIMESTRING>,12)] includes <#wkday> and <time()> of current emit%r [ljust(<IC>,10)] includes whatever is custom written by the game gods%r%rexample...%r%r<~> -6 1067209500~4.0 Sun Oct 26 17:05:00 2003~<IC stuff>%r%rSee also the +help on: ic_time%r
@@
&HELP`IC_TIME ~cron=%rthe <IC> section of the ~cron includes whatever softcoded "IC time" data your local wizards have configured for this portion.%r%r[get(me/note`ufun`cron`ic)]
@@
@@
@@ The following regexp listen patterns were contributed by Mike @ M*U*S*H
@@ for some common listen intervals. Although it's not necessary to use
@@ regexp listen patterns, it can be very useful especially if you wanted
@@ to combine a few of the effects (e.g., opening a secret exit only
@@ on the third Wednesday of the month at precisely midnight).
@@
@@ In each one,
@@ %1 is <TZ~SECS>
@@ %2 is the <N>th Weekday of the month
@@ %3 is the Weekday itself,
@@ %4 the month,
@@ %5 the Day of the Month,
@@ %6 the HH,
@@ %7 the MM,
@@ %8 the SS,
@@ %9 the YYYY
@@ (%0 is the entire com message)
@@ if all the individual %<1-9> registers aren't needed, you can of course
@@ write shorter code.
@@
@@ These are untested, but I think they should work, with the caveat that
@@ if you ever broadcast at intervals of less than one minute,
@@ things will get nasty.
@@
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@
@@ &1M foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (..):(..):(..) (....)$:blah
@@ &2M foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (..):(.[02468]):(..) (....)$:blah
@@ &5M foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (..):(.[05]):(..) (....)$:blah
@@ &10M foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (..):(.0):(..) (....)$:blah
@@ &15M foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (..):(00|15|30|45):(..) (....)$:blah
@@ &20M foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (..):([024]0):(..) (....)$:blah
@@ &30M foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (..):([03]0):(..) (....)$:blah
@@ &1H foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (..):(00):(..) (....)$:blah
@@ &2H foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (.[02468]):(00):(..) (....)$:blah
@@ &3H foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (00|03|06|09|12|15|18|21):(00):(..) (....)$:blah
@@ &4H foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (00|04|08|12|16|20):(00):(..) (....)$:blah
@@ &6H foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (00|06|12|18):(00):(..) (....)$:blah
@@ &8H foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (00|08|16):(00):(..) (....)$:blah
@@ &12H foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (00|12):(00):(..) (....)$:blah
@@ &24H foo=^^<~> (.+)~(.|.\.0) (...) (...) (..) (00):(00):(..) (....)$:blah
@@
@@ ========================================================================
@@ .:....1....:....2....:....3....:....4....:....5....:....6....:....7....:
@@ ------------------------------------------------------------------------
@@
@@ activate
@@
@restart ~cron
@@
@@ The End.