Shell help request: +weather text file writing
-
My google-fu is not turning up the shell-side setup for a piece of +weather code. This shell script presumably grabs the real-world weather for a specific place and sticks it in a text file. The +weather softcode then uses tinymux's textfile() function to read it. I have the softcode, I just don't have the shell knowledge necessary to get the back-end of it working, and I'm not great at Linux or shell scripts or any of that.
How does one go about writing that text file on the server, and then automating that process? (The automation I can probably figure out - it's the writing part that's really got me stumped.) Better yet, if there's a repository or site which hosts and includes help data for this code, please let me know. I've checked the sites listed in the Archive post pinned at the top of the forum and had no luck - if such a site exists, it should probably be added.
-
When I get home I will grab the thinfs from either DW or Reno for the realworld to game +weather, and will contact ronan (try, I will try to contact him). Unfortunately I think the only place he stored that code was on WORA.
-
@Cobaltasaurus, thank you! At least I know I'm not missing some obvious repository.
-
That's a pretty clever way to get data from the filesystem into the game.
If the byte-wise location of the beginning of the help entry can change within the file, a wizard will have to @readcache to have the file reindexed. Similarly, if there's anything in the help file after the weather data a wizard will have to @readcache.
I have an almost-complete weather fetcher and formatter written in golang. I'll see if I can finish it in the next couple of days.
-
https://github.com/AgentZombie/weather
Fetches data from US NWS, Parses the XML, gives you flat output that's easy to restructure.
$ go run bin/fetch.go --weatherurl http://www.weather.gov/xml/current_obs/KSAN.xml
Temperature: 74.0 F (23.3 C)
Wind: Northwest at 9.2 MPH (8 KT)
Pressure: 1014.2 mb
Dewpoint: 51.1 F (10.6 C)
Visibility: 10.00
Humidity: 45
Weather: A Few CloudsIf you don't feel confident setting up the go toolchain I can give you a binary. Note: you should never accept a binary from strangers.
-
@Cobaltasaurus said:
When I get home I will grab the thinfs from either DW or Reno for the realworld to game +weather, and will contact ronan (try, I will try to contact him). Unfortunately I think the only place he stored that code was on WORA.
I have it too. It was originally written for ... I can't remember, now. It's been around since oWoD.
-
I might be off-topic and please let me pointedly put my constructive hat on before I ask this, but here it is:
Is weather code useful for something?
-
@Arkandel said:
I might be off-topic and please let me pointedly put my constructive hat on before I ask this, but here it is:
Is weather code useful for something?
It's another layer of ambiance. The fact that it's raining or windy can change lots of things about combat or just outdoor bar RP. It can be used or ignored.
-
I use it a lot of the time if starting a scene that doesn't need a specific weather if the game has it I will use he +weather. If the scene need a certain weather I ignore the official and go with what helps rp. So yeah it is a neat addition, much like +time.
-
It also helps set a default. You are perfectly within your right to assume a scene is set with the +time/+weather of the game unless informed otherwise--and you should probably ask, if it isn't clear within a set pose.
-
It enhances verisimilitude. It also has vaguely the same psychological magic where it is variable, understandable, vaguely predictable, but still mysterious and handed to you from "on high." That lets player bypass any issues regarding authority if they happen to have them related to who can say what the weather is.
-
@Thenomain said:
@Cobaltasaurus said:
When I get home I will grab the thinfs from either DW or Reno for the realworld to game +weather, and will contact ronan (try, I will try to contact him). Unfortunately I think the only place he stored that code was on WORA.
I have it too. It was originally written for ... I can't remember, now. It's been around since oWoD.
No? No it wasn't. The +Weather code on DW, Reno, TR, etc. was coded by ronan/grey at my request for DW. Unless he based it off of an older code it was another of the 'coded for darkwater' code that's floating about. : P
-
This is what is on the reno shell for the php of the code:
/****************************************************************************** * * User configuration section. Please read included comments. * *****************************************************************************/ // Set the zipecode below to the zipcode you wish to gather weather information for. $zip = "89502"; // Set the $units variable to 'f' for Fahrenheit or 'c' for Celsius. $units = "f"; // If you are following the instructions then this variable should not need changing. $file = 'mux2.10/game/text/weather.txt'; /****************************************************************************** * * No configuration is required beyond this point. * *****************************************************************************/ $feed = 'http://weather.yahooapis.com/forecastrss?p=' . $zip . '&u=' . $units; $content = file_get_contents( $feed ); $rss = simplexml_load_string( $content ); if( !$rss ) die( 'Failed to retrieve RSS Weather feed' ); $copyright = $rss->channel->copyright; $base = $rss->channel->children( "http://xml.weather.yahoo.com/ns/rss/1.0" ); foreach( $base as $x => $base_item ) foreach( $base_item->attributes() as $k => $attr ) $channel[$x][$k] = $attr; $base = $rss->channel->item->children( "http://xml.weather.yahoo.com/ns/rss/1.0" ); foreach( $base as $x => $base_item ) { foreach( $base_item->attributes() as $k => $attr ) { if( $k == 'day' ) $day = $attr; if( $x == 'forecast' ) { $forecast[$x][$day . ''][$k] = $attr; } else { $forecast[$x][$k] = $attr; } } } $fr = fopen( $file, 'w' ); fputs( $fr, "&help\n" ); fputs( $fr, "Raw weather data for weather code.\n" ); $items = array( "units", "wind", "atmosphere", "astronomy" ); foreach( $items as $x ) { @fputs( $fr, "\n& " . $x . "\n" ); foreach( $channel[$x] as $val ) { @fputs( $fr, $val . ';' ); } } fputs( $fr, "\n& condition \n" ); foreach( $forecast['condition'] as $key => $val ) { if ( $key == "date" ) { @fputs( $fr, strtotime( $val ) . ';' ); } else { @fputs( $fr, $val . ';' ); } } $count = 1; foreach( $forecast['forecast'] as $x => $y ) { fputs( $fr, "\n& forecast" . $count . " \n" ); foreach( $forecast['forecast'][$x] as $key => $val ) { if ( $key == "date" ) { @fputs( $fr, strtotime( $val ) . ';' ); } else { @fputs( $fr, $val . ";" ); } } $count++; } @fclose( $fr ); ?>
This is what is on darkwater for the soft code:
&L.CATS Weather Code Framework=units;wind;atmosphere;astronomy;condition;forecast1;forecast2 &L.CATS-UNITS Weather Code Framework=temperature;distance;pressure;speed &L.CATS-WIND Weather Code Framework=chill;direction;speed &L.CATS-ASTRONOMY Weather Code Framework=rising;setting &L.CATS-CONDITION Weather Code Framework=text;code;temperature;date &L.CATS-FORECAST1 Weather Code Framework=day;date;low;high;text;code &L.CATS-FORECAST2 Weather Code Framework=day;date;low;high;text;code &FN.CONVERT-WIND Weather Code Framework=switch(1,and(gte(%0,11.25),lte(%0,33.75)),NNE,and(gte(%0,33.75),lte(%0,56.25)),NE,and(gte(%0,56.65),lte(%0,78.75)),ENE,and(gte(%0,78.75),lte(%0,101.25)),E,and(gte(%0,101.25),lte(%0,123.75)),ESE,and(gte(%0,123.75),lte(%0,146.25)),SE,and(gte(%0,146.25),lte(%0,168.75)),SSE,and(gte(%0,168.75),lte(%0,191.25)),S,and(gte(%0,191.25),lte(%0,213.75)),SSW,and(gte(%0,213.75),lte(%0,236.25)),SW,and(gte(%0,236.25),lte(%0,258.75)),WSW,and(gte(%0,258.75),lte(%0,281.25)),W,and(gte(%0,281.25),lte(%0,303.75)),WNW,and(gte(%0,303.75),lte(%0,326.25)),NW,and(gte(%0,326.25),lte(%0,348.75)),NNW,or(and(gte(%0,348.75),lte(%0,360)),and(gte(%0,0),lte(%0,11.25))),N,ERR) &I.FILE Weather Code Framework=weather &FN.GETTEMP Weather Code Framework=setq(0,extract(textfile(v(I.FILE),condition),3,1,;))[switch(extract(textfile(v(I.FILE),units),1,1,;),F,%q0 F %([round(fdiv(sub(%q0,32),1.8),2)] C%),C,%q0 C %([round(add(mul(%q0,1.8),32),2)] F%))] &FN.GETSHORTTEMP Weather Code Framework=setq(0,extract(textfile(v(I.FILE),condition),3,1,;))[switch(extract(textfile(v(I.FILE),units),1,1,;),F,%q0 F,C,%q0 C)] &FN.GETCONDITION Weather Code Framework=extract(textfile(v(I.FILE),condition),1,1,;) &FN.GETCODE Weather Code Framework=extract(textfile(v(I.FILE),condition),2,1,;) &FN.GETDATE Weather Code Framework=extract(textfile(v(I.FILE),condition),4,1,;) &FN.GETSUNRISE Weather Code Framework=extract(textfile(v(I.FILE),astronomy),1,1,;) &FN.GETSUNSET Weather Code Framework=extract(textfile(v(I.FILE),astronomy),2,1,;) &FN.GETWIND Weather Code Framework=setq(0,textfile(v(I.FILE),wind))[setq(1,extract(%q0,3,1,;))][setq(2,extract(%q0,2,1,;))][switch(setr(3,extract(textfile(v(I.FILE),units),4,1,;)),mph,%q1 [ucstr(%q3)] [u(FN.CONVERT-WIND,%q2)] %([round(mul(%q1,1.609344),2)] KPH%),kph,%q1 [ucstr(%q3)] [u(FN.CONVERT-WIND,%q2)] %([round(fdiv(%q1,1.609344),2)] MPH%))] &FN.GETSHORTWIND Weather Code Framework=setq(0,textfile(v(I.FILE),wind))[setq(1,extract(%q0,3,1,;))][setq(2,extract(%q0,2,1,;))][switch(setr(3,extract(textfile(v(I.FILE),units),4,1,;)),mph,%q1 [ucstr(%q3)] [u(FN.CONVERT-WIND,%q2)],kph,%q1 [ucstr(%q3)] [u(FN.CONVERT-WIND,%q2)])] &FN.GETWINDCHILL Weather Code Framework=setq(0,extract(textfile(v(I.FILE),wind),1,1,;))[setq(1,extract(textfile(v(I.FILE),units),1,1,;))][switch(%q1,F,%q0 F %([round(fdiv(sub(%q0,32),1.8),2)] C%),C,%q0 C %([round(add(mul(%q0,1.8),32),2)] F%))] &FN.GETSHORTWINDCHILL Weather Code Framework=setq(0,extract(textfile(v(I.FILE),wind),1,1,;))[setq(1,extract(textfile(v(I.FILE),units),1,1,;))][switch(%q1,F,%q0 F,C,%q0 C)] &FN.GETVIS Weather Code Framework=[setq(0,extract(textfile(v(I.FILE),atmosphere),2,1,;))][setq(1,extract(textfile(v(I.FILE),units),2,1,;))][switch(%q1,mi,%q0 Miles %([round(mul(%q0,1.609344),2)] KM%),km,%q0 Kilometers %([round(fdiv(%q0,1.609344),2)] MI%))] &FN.GETSHORTVIS Weather Code Framework=[setq(0,extract(textfile(v(I.FILE),atmosphere),2,1,;))][setq(1,extract(textfile(v(I.FILE),units),2,1,;))][switch(%q1,mi,%q0 Miles,km,%q0 Kilometers)] &FN.GETHUMIDITY Weather Code Framework=[extract(textfile(v(I.FILE),atmosphere),1,1,;)]%% &FN.GETPRES Weather Code Framework=[extract(textfile(v(I.FILE),atmosphere),3,1,;)][extract(textfile(v(I.FILE),units),3,1,;)] &FN.GETPRESSTATE1 Weather Code Framework=switch(extract(textfile(v(I.FILE),atmosphere),4,1,;),0,=,1,^,2,v,=) &FN.GETPRESSTATE2 Weather Code Framework=extract(textfile(v(I.FILE),atmosphere),4,1,;) &FN.GETFORECAST Weather Code Framework=ifelse(and(t(match(v(L.CATS-FORECAST1),%1,;)),t(match(today;tmw,%0,;)),t(match(long;short,%2,;))),u(FN.FORECAST[switch(%2,short,SHORT,)]%1,%0),ERROR: Incorrect usage.) &FN.FORECASTLOW Weather Code Framework=setq(0,extract(textfile(v(I.FILE),forecast[switch(%0,today,1,tmw,2)]),3,1,;))[setq(1,extract(textfile(v(I.FILE),units),1,1,;))][switch(%q1,C,%q0 C %([round(add(mul(%q0,1.8),32),2)] F%),F,%q0 F %([round(fdiv(sub(%q0,32),1.8),2)] C%))] &FN.FORECASTHIGH Weather Code Framework=setq(0,extract(textfile(v(I.FILE),forecast[switch(%0,today,1,tmw,2)]),4,1,;))[setq(1,extract(textfile(v(I.FILE),units),1,1,;))][switch(%q1,C,%q0 C %([round(add(mul(%q0,1.8),32),2)] F%),F,%q0 F %([round(fdiv(sub(%q0,32),1.8),2)] C%))] &FN.FORECASTSHORTLOW Weather Code Framework=setq(0,extract(textfile(v(I.FILE),forecast[switch(%0,today,1,tmw,2)]),3,1,;))[setq(1,extract(textfile(v(I.FILE),units),1,1,;))][switch(%q1,C,%q0 C,F,%q0 F)] &FN.FORECASTSHORTHIGH Weather Code Framework=setq(0,extract(textfile(v(I.FILE),forecast[switch(%0,today,1,tmw,2)]),4,1,;))[setq(1,extract(textfile(v(I.FILE),units),1,1,;))][switch(%q1,C,%q0 C,F,%q0 F)] &FN.FORECASTDAY Weather Code Framework=setq(0,extract(textfile(v(I.FILE),forecast[switch(%0,today,1,tmw,2)]),1,1,;))[switch(%q0,Sun,Sunday,Mon,Monday,Tue,Tuesday,Wed,Wednesday,Thu,Thursday,Fri,Friday,Sat,Saturday)] &FN.FORECASTSHORTDAY Weather Code Framework=setq(0,extract(textfile(v(I.FILE),forecast[switch(%0,today,1,tmw,2)]),1,1,;))[switch(%q0,Sun,0,Mon,1,Tue,2,Wed,3,Thu,4,Fri,5,Sat,6)] &FN.FORECASTDATE Weather Code Framework=setq(0,extract(textfile(v(I.FILE),forecast[switch(%0,today,1,tmw,2)]),2,1,;))[timefmt($a $b $d $Y,%q0)] &FN.FORECASTSHORTDATE Weather Code Framework=extract(textfile(v(I.FILE),forecast[switch(%0,today,1,tmw,2)]),2,1,;) &FN.FORECASTTEXT Weather Code Framework=extract(textfile(v(I.FILE),forecast[switch(%0,today,1,tmw,2)]),5,1,;) &FN.FORECASTSHORTTEXT Weather Code Framework=extract(textfile(v(I.FILE),forecast[switch(%0,today,1,tmw,2)]),6,1,;) &C.+WEATHER Weather Code Framework=$+weather:@pemit %#=[setq(b,v(I.ANSI-HEADER))][setq(a,g)][header(Time %& Weather)]%r%r[center(ansi( %qa, Current Time),78)]%r[center([setq(0, extract(setr(2, convsecs(sub(secs(), 10800))), 4, 1))][setq(1, extract(%q0, 1, 1, :))][if(gt(%q1, 12), [sub(%q1, 12)]:[extract(%q0, 2, 1, :)], %q1:[extract(%q0, 2, 1, :)])] [if(gte(%q1, 12), pm, am)] on [extract(%q2, 1,3)]%b[extract(%q2, 5, 1)], 78)]%r%r[center(ansi(%qa,Current Conditions),79)]%r%r[rjust(ansi(%qa, Temp:%b),12)][ljust(ulocal(FN.gettemp),25)][rjust(ansi(%qa,Sunrise:%b),12)][ljust(ulocal(FN.GETSUNRISE),30)]%r[ rjust(ansi(%qa,Wind:%b),12)][ljust(ulocal(FN.GETWIND),25)][rjust(ansi(%qa,Sunset:%b),12)][ljust(ulocal(FN.GETSUNSET),30)]%r[rjust(ansi(%qa,Condition:%b),12)][ljust(ulocal(FN.GETCONDITION),25)][rjust(ansi(%qa,Wind Chill:%b),12)][ljust(ulocal(FN.GETWINDCHILL),30)]%r[rjust(ansi(%qa,Humidity:%b),12)][ljust(ulocal(FN.GETHUMIDITY), 25)][rjust(ansi(%qa,Visibility:%b),12)][ljust(ulocal(FN.GETVIS),30)]%r[rjust(ansi(%qa,Pressure:%b),12)][ljust([ulocal(FN.GETPRES)]%b[switch(ulocal(FN.GETPRESSTATE2),0,Steady,1,Rising,2,Falling)], 24)]%r%r%r[space(12)][center(ansi(%qa,Today's Forecast),33)][center(ansi(%qa,Tomorrow's Forecast),33)]%r%r[rjust(ansi(%qa,Low:%b),12)][center(ulocal(FN.getforecast,today,low,long),33)][center(ulocal(FN.GETFORECAST,tmw,low,long),33)]%r[rjust(ansi(%qa,High:%b),12)][center(ulocal(FN.GETFORECAST,today,high,long),33)][center(ulocal(FN.GETFORECAST,tmw,high,long),33)]%r[rjust(ansi(%qa,Condition:%b),12)][center(ulocal(FN.GETFORECAST,today,text,long),33)][center(ulocal(FN.GETFORECAST,tmw,text,long),33)]%r%r[footer()] &I.ANSI-HEADER Weather Code Framework=hy &I.ANSI-SUBHEADER Weather Code Framework=hg &L.CATS-ATMOSPHERE Weather Code Framework=humidity;visibility;pressure;state &C.+WEATHER/FILE Weather Code Framework=$+weather/file:@pemit %#=[center(| Weather.txt Structure |,79,-)]%r%r& help%r[space(5)]Irrelevant basic entry%r[iter(get(#191/L.CATS),& [itext()]%r[space(5)][iter(get(#191/L.CATS-[itext()]),itext(),;,%b:%b)],;,%r)]%r%r[repeat(-,79)] &L.CATS-MOON Weather Code Framework=percent illumination;phase name;waxing waning &FN.GETMOONPHASE Weather Code Framework=[setq(0, extract(textfile(v(I.FILE),moon),3,1,;))][if(t(%q0), %q0%b)][extract(textfile(v(I.FILE),moon),2,1,;)] &FN.GETMOONPERCENT Weather Code Framework=extract(textfile(v(I.FILE),moon),1,1,;) @set Weather Code Framework=SAFE @rxlevel Weather Code Framework= @txlevel Weather Code Framework=
I don't remember all of the steps to get it working, but those are the pieces of it.
Oh right: You have to create weather.php with the info above, and you need to create a weather.txt file that it points at.
-
Steps I followed, for posterity's sake:
- Stick a <?php at the front of that PHP file. Save it in your shell account's root directory.
- On the game, create the weather softcode object (probably obvious but still important).
- Shell commands:
touch mux2.10/game/text/weather.txt
The purpose of that was to create the weather file - a nice, empty file. There's probably an easier way to do it but that's what I did.
ctrl-X yes, enter nano mux2.10/game/netmux.conf
Under where it says wizhelp text/wizhelp add this line:
helpfile weather text/weather
Then:
ctrl-X yes, enter php5 -f weather.php
- On your game, hit @restart.
Voila, weather!
One more step to undertake, though:
- Make it run every hour. In your shell account, do this:
crontab -e
Before # end, type:
0 * * * * php5 -f weather.php
Warning: if you're on a standard system, you're now in VI. Your server might be configured differently, however. You can tell it's emacs by the "File Edit ..." at the top. Nano is pretty obvious by the highlighted commands with simple text at the bottom. This is a minor pain in the ass if you're not familiar with Linux commands. So, three different quit commands to try - but be aware that they won't work for the wrong editor. Determine the editor FIRST, then try the command.
Vi: ESC-:wq Emacs: Ctrl-X-S, Ctrl-X-C Nano: ctrl-X, Yes, enter
That was an exercise in education right there. Shells aren't my thing, but they're definitely interesting.
Thank you @Cobaltasaurus and @Sponge, I really appreciate the help!
@Misadventure, upvoted for truth.
-
Right after getting that working, I had a request to make it work with moon phases. So, I did the following to the PHP file:
<?php /****************************************************************************** * * User configuration section. Please read included comments. * *****************************************************************************/ // Set the zipecode below to the zipcode you wish to gather weather information for. $zip = "70116"; // Set the $units variable to 'f' for Fahrenheit or 'c' for Celsius. $units = "f"; // If you are following the instructions then this variable should not need changing. $file = 'mux2.10/game/text/weather.txt'; /****************************************************************************** * * No configuration is required beyond this point. * *****************************************************************************/ $feed = 'http://weather.yahooapis.com/forecastrss?p=' . $zip . '&u=' . $units; $content = file_get_contents( $feed ); $rss = simplexml_load_string( $content ); if( !$rss ) die( 'Failed to retrieve RSS Weather feed' ); $copyright = $rss->channel->copyright; $base = $rss->channel->children( "http://xml.weather.yahoo.com/ns/rss/1.0" ); foreach( $base as $x => $base_item ) foreach( $base_item->attributes() as $k => $attr ) $channel[$x][$k] = $attr; $base = $rss->channel->item->children( "http://xml.weather.yahoo.com/ns/rss/1.0" ); foreach( $base as $x => $base_item ) { foreach( $base_item->attributes() as $k => $attr ) { if( $k == 'day' ) $day = $attr; if( $x == 'forecast' ) { $forecast[$x][$day . ''][$k] = $attr; } else { $forecast[$x][$k] = $attr; } } } $fr = fopen( $file, 'w' ); fputs( $fr, "&help\n" ); fputs( $fr, "Raw weather data for weather code.\n" ); $items = array( "units", "wind", "atmosphere", "astronomy" ); foreach( $items as $x ) { @fputs( $fr, "\n& " . $x . "\n" ); foreach( $channel[$x] as $val ) { @fputs( $fr, $val . ';' ); } } fputs( $fr, "\n& condition \n" ); foreach( $forecast['condition'] as $key => $val ) { if ( $key == "date" ) { @fputs( $fr, strtotime( $val ) . ';' ); } else { @fputs( $fr, $val . ';' ); } } $count = 1; foreach( $forecast['forecast'] as $x => $y ) { fputs( $fr, "\n& forecast" . $count . " \n" ); foreach( $forecast['forecast'][$x] as $key => $val ) { if ( $key == "date" ) { @fputs( $fr, strtotime( $val ) . ';' ); } else { @fputs( $fr, $val . ";" ); } } $count++; } $timestamp = time(); $year = date('Y', $timestamp); $month = date('n', $timestamp); $day = date('j', $timestamp); $c = $e = $jd = $b = 0; $lunar_phase =""; $waxingwaning =""; $percentage=""; if ($month < 3) { $year--; $month += 12; } ++$month; $c = 365.25 * $year; $e = 30.6 * $month; $jd = $c + $e + $day - 694039.09; //jd is total days elapsed $jd /= 29.5305882; //divide by the moon cycle $percentage = round($jd / 100); $b = (int) $jd; //int(jd) -> b, take integer part of jd $jd -= $b; //subtract integer part to leave fractional part of original jd $b = round($jd * 8); //scale fraction from 0-8 and round if ($b >= 8 ) { $b = 0;//0 and 8 are the same so turn 8 into 0 } switch ($b) { case 0: $lunar_phase = 'New Moon'; break; case 1: $lunar_phase = 'Crescent Moon'; $waxingwaning = 'Waxing'; break; case 2: $lunar_phase = 'Quarter Moon'; $waxingwaning = 'Waxing'; break; case 3: $lunar_phase = 'Gibbous Moon'; $waxingwaning = 'Waxing'; break; case 4: $lunar_phase = 'Full Moon'; break; case 5: $lunar_phase = 'Gibbous Moon'; $waxingwaning = 'Waning'; break; case 6: $lunar_phase = 'Quarter Moon'; $waxingwaning = 'Waning'; break; case 7: $lunar_phase = 'Crescent Moon'; $waxingwaning = 'Waning'; break; default: $lunar_phase = 'Error'; } fputs( $fr, "\n& moon \n" ); fputs( $fr, $percentage); fputs( $fr, ";"); fputs( $fr, $lunar_phase); fputs( $fr, ";"); fputs( $fr, $waxingwaning ); @fclose( $fr ); ?>
And then, slight changes to the softcode:
&C.+WEATHER Weather Code Framework=$+weather:@pemit %#=[setq(b,v(I.ANSI-HEADER))][setq(a,g)][header(Time %& Weather)]%r%r[center(ansi( %qa, Current Time),78)]%r[center([setq(0, extract(setr(2, convsecs(sub(secs(), 10800))), 4, 1))][setq(1, extract(%q0, 1, 1, :))][if(gt(%q1, 12), [sub(%q1, 12)]:[extract(%q0, 2, 1,:)], %q1:[extract(%q0, 2, 1, :)])] [if(gte(%q1, 12), pm, am)] on [extract(%q2,1,3)]%b[extract(%q2, 5, 1)], 78)]%r%r[center(ansi(%qa,Current Conditions),79)]%r%r[rjust(ansi(%qa, Temp:%b),12)][ljust(ulocal(FN.gettemp),25)][rjust(ansi(%qa,Sunrise:%b),12)][ljust(ulocal(FN.GETSUNRISE),30)]%r[ rjust(ansi(%qa,Wind:%b),12)][ljust(ulocal(FN.GETWIND),25)][rjust(ansi(%qa,Sunset:%b),12)][ljust(ulocal(FN.GETSUNSET),30)]%r[rjust(ansi(%qa,Condition:%b),12)][ljust(ulocal(FN.GETCONDITION),25)][rjust(ansi(%qa,Wind Chill:%b),12)][ljust(ulocal(FN.GETWINDCHILL),30)]%r[rjust(ansi(%qa,Humidity:%b),12)][ljust(ulocal(FN.GETHUMIDITY), 25)][rjust(ansi(%qa,Visibility:%b),12)][ljust(ulocal(FN.GETVIS),30)]%r[rjust(ansi(%qa,Pressure:%b),12)][ljust([ulocal(FN.GETPRES)]%b[switch(ulocal(FN.GETPRESSTATE2),0,Steady,1,Rising,2,Falling)], 24)][rjust(ansi(%qa,Moon:%b),13)][ljust([u(fn.getmoonphase)]%b%([u(fn.getmoonpercent)]%%%),30)]%r%r%r[space(12)][center(ansi(%qa,Today's Forecast),33)][center(ansi(%qa,Tomorrow's Forecast),33)]%r%r[rjust(ansi(%qa,Low:%b),12)][center(ulocal(FN.getforecast,today,low,long),33)][center(ulocal(FN.GETFORECAST,tmw,low,long),33)]%r[rjust(ansi(%qa,High:%b),12)][center(ulocal(FN.GETFORECAST,today,high,long),33)][center(ulocal(FN.GETFORECAST,tmw,high,long),33)]%r[rjust(ansi(%qa,Condition:%b),12)][center(ulocal(FN.GETFORECAST,today,text,long),33)][center(ulocal(FN.GETFORECAST,tmw,text,long),33)]%r%r[footer()] &FN.GETMOONPHASE Weather Code Framework=[setq(0, extract(textfile(v(I.FILE),moon),3,1,;))][if(t(%q0), %q0%b)][extract(textfile(v(I.FILE),moon),2,1,;)] &FN.GETMOONPERCENT Weather Code Framework=extract(textfile(v(I.FILE),moon),1,1,;) &L.CATS Weather Code Framework=units;wind;atmosphere;astronomy;condition;forecast1;forecast2;moon
And thus there is now a moon phase and illumination.
Note: I cannot take credit for any of this code except the most minor of modifications to c.+weather (call the already-existing ufuns! whee!) - the PHP code is slightly modified from http://jivebay.com/calculating-the-moon-phase/, and the softcode came from copying other softcode and changing it slightly.
-
At :01 of every hour you will need to use
@readcache
or the news file being read will be either too small or too large for the information loaded into it from PHP. -
@Thenomain Weird, I didn't have that problem. It seems to change automagically since the file is rewritten every time the PHP command is run. (It should always be about the same length save for a slight difference in the number of characters per line.)
-
@Melpomene, Try it sometime. Manually change 'sunny' to 'partially cloudy' then type 'weather conditions' and it should cut off part of it.
Any time you change a server-side help or news file, you must re-run @readcache. N.b., TinyMUX or TinyMUSH. I don't know how Penn or Rhost deal with it.
-
@Melpomene said:
nano mux2.10/game/text/weather.txt test ctrl-X yes, enter nano mux2.10/game/text/weather.txt Ctrl-K Ctrl-K Ctrl-K
An easy way to create an empty file in the shell is to use "touch".
touch mux2.10/game/text/weather.txt
-
@Glitch Thanks - updated my instructions. That will be useful in the future!