@program #340 1 1000 d i $def rpsys "$rpsystem" match $include $lib/alynna $include $lib/rp $def notify ansi_notify $def notify_except ansi_notify_except lvar target $include $muf/Scrp/registry $include $lib/gary'sMufUtils-strings lvar diff lvar year lvar month lvar day lvar hour lvar minute lvar second lvar meridian lvar moon lvar total lvar daylight lvar wind lvar rain lvar temp lvar clouds lvar season : analyzer ( i -- s ) total ! total @ 1 < if "pratically non-existant" exit then total @ 2 < if "faint" exit then total @ 3 < if "slight" exit then total @ 4 < if "occasional" exit then total @ 5 < if "moderate" exit then total @ 6 < if "moderate to heavy" exit then total @ 7 < if "heavy" exit then total @ 8 < if "very heavy" exit then total @ 9 < if "extreme" exit then "unbeleivable" ; : reporttime #0 "Globaltime" getstatint systime swap - 2.5 * int diff ! diff @ 60 % second ! diff @ 3600 % 60 / minute ! diff @ 86400 % 3600 / hour ! diff @ 2592000 % 86400 / 1 + day ! diff @ 31536000 % 2592000 / 1 + month ! diff @ 2551440 % 255144 / moon ! diff @ 31536000 / year ! month @ 12 > if month @ 12 - month ! then str "^blue^<^Yellow^IC TIME^blue^>^ ^ It's " hour @ dup 11 > if 12 - 1 meridian ! else 0 meridian ! then dup not if pop 12 then ":" minute @ dup 10 < if intostr "0" swap strcat then " " meridian @ if "PM" else "AM" then ", " #0 "days/" diff @ 604800 % 86400 / 1 + intostr strcat getpropstr ", " day @ english_number " day of the " month @ intostr "{12|1|2}" smatch if "winter" then month @ intostr "{3|4|5}" smatch if "spring" then month @ intostr "{6|7|8}" smatch if "summer" then month @ intostr "{9|10|11}" smatch if "fall" then " month " #0 "month/" month @ intostr strcat getpropstr " in the year " year @ 2472 + " AC " rpsys str "holidays/" month @ "/" day @ cat getpropstr dup not if pop rpsys str "holidays/" month @ "/" day @ 1 + cat getpropstr dup if " Eve" else pop rpsys str "holidays/" month @ "/" day @ 1 - cat getpropstr dup if " winding up" else pop then then then cat .tell str "^blue^<^Yellow^IC WEATHER^blue^>^ ^ It's currently " #0 "@rp/currweather" getpropstr dup not if pop #0 "Temp" getstatfloat 1 fchop " degrees F (" #0 "Temp" getstatfloat 32 - 5.0 * 9.0 / 1 fchop "C) with a " #0 "Clouds" getstatfloat analyzer " cloud cover" #0 "Rain" getstatfloat if " and " #0 "Rain" getstatfloat analyzer #0 "Temp" getstatfloat 32 > if " rain" else " snow" then then #0 "clouds" getstatfloat clouds ! hour @ 8 < hour @ 20 > or clouds @ 5 < and if ", In the sky, the moon is " moon @ 0 = if "waxing new" then moon @ 1 = if "waxing crescent" then moon @ 2 = if "waxing half" then moon @ 3 = if "waxing gibbous" then moon @ 4 = if "waxing full" then moon @ 5 = if "waning full" then moon @ 6 = if "waning gibbous" then moon @ 7 = if "waning half" then moon @ 8 = if "waning crescent" then moon @ 9 = if "waning new" then then then cat .tell ; : init ( -- ) "Global time not found, declaring this to be AH 1003, January first, midnight" .tell #0 "Globaltime" systime setstat reporttime ; : var-init ( -- ) #0 "Globaltime" getstatint systime swap - 2.5 * int diff ! diff @ 60 % second ! diff @ 3600 % 60 / minute ! diff @ 86400 % 3600 / hour ! diff @ 2592000 % 86400 / 1 + day ! diff @ 31536000 % 2592000 / 1 + month ! diff @ 2551440 % 255144 / moon ! diff @ 31536000 / year ! month @ 12 > if month @ 12 - month ! then ; : temperature-control ( -- i ) var-init month @ 0 = if 40 then month @ 1 = if 48 then month @ 2 = if 56 then month @ 3 = if 60 then month @ 4 = if 62 then month @ 5 = if 68 then month @ 6 = if 76 then month @ 7 = if 85 then month @ 8 = if 80 then month @ 9 = if 72 then month @ 10 = if 60 then month @ 11 = if 50 then month @ 12 = if 45 then hour @ 8 < if #0 "Day?" 0 setstat hour @ 4 minute @ 60.0 / + + - then hour @ 19 > if #0 "Day?" 0 setstat hour @ 20 - minute @ 60.0 / + - then hour @ 7 > hour @ 15 < and if #0 "Day?" 1 setstat hour @ 8 - minute @ 60.0 / + + then hour @ 14 > hour @ 20 < and if hour @ 15 - minute @ 60.0 / + 2.0 / 7 + + then year @ 5 + 20 % 1 + dup 10 > if 20 swap - then + day @ 10 % 1 + dup 5 > if 10 swap - then 2 - 2.0 / + ( 15 hour @ minute @ 60.0 / + - dup not if 1 then fabs 5.0 swap / + ) ( hour @ 8 > hour @ 20 < and not if hour @ minute @ 60.0 / + dup 20 > if 24 - then 3 swap - dup not if 1 then fabs 5.0 swap / - then ) .debug-off temp ! clouds @ if clouds @ -0.01 * temp @ + temp ! then #0 "Temp" temp @ setstat day @ year @ month @ + + 10 % 1 + #0 "Clouds" rot setstat day @ year @ month @ + + 5 % not if hour @ day @ year @ + + 24 % dup 23 swap - "Today it will rain: " swap intostr strcat debug 6 < if "It should rain now" debug month @ year @ + 10 % 1 + rain ! then then #0 "Rain" rain @ setstat ; : weathershift ( -- ) month @ intostr "{12|1|2}" smatch if "winter" then month @ intostr "{3|4|5}" smatch if "spring" then month @ intostr "{6|7|8}" smatch if "summer" then month @ intostr "{9|10|11}" smatch if "fall" then season ! #0 "temp" getstatfloat temp ! #0 "clouds" getstatfloat clouds ! #0 "rain" getstatfloat rain ! rain @ 0 < if 0 rain ! then rain @ 10 > if rain @ -0.5 + rain ! then clouds @ random day @ 13 % month @ 3 % 1 + * 2.0 / int % 1 + 6 - 0.01 * + clouds ! random 20 % not if clouds @ random 12 % 1 + 6 - 0.2 * + clouds ! then clouds @ 0 < if 0 clouds ! then clouds @ 10 > if clouds @ -0.5 + clouds ! then season @ "Winter" smatch if random 2 % if hour @ 8 > hour @ 20 < and if 0.05 temp @ + temp ! else -0.05 temp @ + temp ! then then clouds @ 2 < random 3 % not and if clouds @ random 5 % 1 + 0.1 * + clouds ! then then season @ "Spring" smatch if random 2 % if hour @ 8 > hour @ 20 < and if 0.05 temp @ + temp ! else -0.05 temp @ + temp ! then then random 2 % if clouds @ random 5 % 0.1 * + clouds ! then random 200 % not if rain @ not if random 10 % 1 + rain ! then clouds @ rain @ < if clouds @ 2 * clouds ! then then rain @ if rain @ random 4 % 0.1 * - rain ! then then str " Temp: " temp @ " clouds: " clouds @ " Rain: " rain @ cat debug ; : pulser ( -- ) begin #0 "Globaltime" getstatint systime swap - 2.5 * int diff ! diff @ 86400 % 3600 / hour ! diff @ 60 % second ! diff @ 3600 % 60 / minute ! diff @ 31104000 % 17452800 - dup 0 < if 0 swap - then daylight ! diff @ 2592000 % 86400 / 1 + day ! diff @ 31104000 % 2592000 / 1 + month ! random 60 % not if weathershift then hour @ not #0 "Midnight?" getstatint not and if #0 "Midnight?" 1 setstat #0 "Dawn?" 0 setstat #21 "@Wall !The deep darkness of night pervades all, the sounds of night crickets chirp quietly as the witching hour passes." force #0 "temp" getstatint random 3 % 1 + 2 - 0.5 * + #0 "temp" rot setstat #0 "clouds" getstatint random 3 % 1 + 2 - 0.5 * + #0 "clouds" rot setstat then hour @ 12 = #0 "Noon?" getstatint not and if #0 "Noon?" 1 setstat #0 "Dusk?" 0 setstat #21 "@Wall !The sun shines high overhead, the city bustles with activity as the church bells herald the coming of noon." force then hour @ 8 = #0 "Dawn?" getstatint not and if #0 "Dawn?" 1 setstat #0 "Midnight?" 0 setstat #21 "@Wall !The sun slowly rises over the horizon. The gates are raised minutes later, the city resuming its daily cycle of life." force #3362 "" setlockstr #3360 "" setlockstr then hour @ 20 = #0 "Dusk?" getstatint not and if #0 "Dusk?" 1 setstat #0 "Midnight?" 0 setstat #21 "@Wall !The sun slowly sinks over the horizon. The gates are lowered minutes later, the city slowly settling into sleep." force #3362 "#0" setlockstr #3360 "#0" setlockstr then 10 2.5 / int sleep 0 until ; : main ( s -- ) temperature-control #0 "globaltime" getstatint not if init then trigger @ #-1 dbcmp swap "connect" instring not and if pulser main then reporttime ; . c q