Using the weather

This is based on the original weather documentation with a number of corrections and additions of my own. To have the weather installed in your area, please contact Woof who will make you 2 items which will be the controller of your weather system. She will inform you when the weather is working in your area. If you do not have weather in your area the following will not work - but you can read it and see just how much fun you can have. You can also make locks against things, so you could have a door which didn't open if it was too windy...

MUF Programming >>

[Weather quick reference]

I've tried to keep the MPI routines simple so that those with even minimal MPI knowledge should be able to follow the example. You should be familiar with the MPI commands {exec:}, {if:} and {with:}... they're used most often. The more complex MPI commands are formatted for readability.

This example is for a room called...
A Meadow in the Forest with a Stream

--[ main description ]--

@desc = You stand in a meadow amidst a forest. The surrounding trees are thick and form a large clearing that is criss-crossed by a few animal paths. Through the centre of the meadow, a brook runs through with a small waterfall that is {exec:desc/waterfall}. {exec:desc/daytime}. {exec:desc/temp} {exec:desc/breeze}. {exec:desc/season}. {exec:desc/precip}{exec:desc/sky}

The first part of this room description is constant. The rest executes MPI routines which will use the {weather} MPI global to vary the room description. There is nothing special about the propdir 'desc', I just put all these MPI routines there just to keep things organised.

Normally I've set things up so that the final period '.' is in the main description for each of the MPI-evaluated sentences.

--[ waterfall ]-- ( here that sentence about the waterfall is finished )

desc/waterfall = {if:{gt:{weather:tempc},0} ,roaring softly as it falls over some rocks ,frozen solid in the chilly weather}

--[ daytime ]-- ( a sentence or two describing the day )

desc/daytime = {exec:daytime/{weather:daytime}}

This simple routine seems to pop up over and over again {weather:daytime} can result in seven possible values dawn, sunrise, morning, afternoon, dusk, sunset, night.

Seven properties should be added to the room to deal with each condition. Again, there's nothing special about the fact that I put them in a propdir called 'daytime'. You could in fact use {exec:{weather:daytime}} and put the values in properties called 'dawn', 'sunrise', etc.

daytime/dawn = The sun is just rising behind the clouds to the east. The songs of birds can be heard as the new day begins
daytime/sunrise = You see the sun rising over the treetops to the east. The eastern sky is ablaze with deep orange and golden yellow waves daytime/morning = The sounds of many animals can be heard as they begin their daily tasks
daytime/afternoon = It is a quiet afternoon in the meadow. You can hear the brook babble and the birds sing but little else seems to be about at this time
daytime/dusk = Behind the clouds to the west, you can tell the sun is setting. It is getting cooler in the meadow as night falls
daytime/sunset = In the west, you see a glorious sunset that seems to reach across the skies with rivers of deep red, dark purple and brilliant oranges
daytime/night = It is dark here in the meadow, you can barely see you hand in front of your face. Every now and then you hear a noise that makes you wonder just what sort of animals wonder about at night in meadows such as this

--[ temp ]-- ( we begin a sentence talking about the air... )

desc/temp = The air is quite {weather:temp}

--[ breeze ]-- ( and finish the sentence here. )

desc/breeze = and {exec:breeze/{weather:wind}}

Here's that structure again

breeze/calm = very still
breeze/breezy = a light breeze wafts by
breeze/gusty = occasional gusts of wind blow through the meadow
breeze/windy = a steady wind whistles throw the meadow
breeze/hi_wind = high winds howl through the meadow


--[ season ]-- ( Here we describe the season )

desc/season: It is {weather:season} and the meadow exec:season/{weather:season}}
season/spring = is now covered with dark rich emerald green grass and beautiful wildflowers as far as the eye can see
season/summer = is lush with green grass and alive with the sounds of many insects buzzing about
season/fall = is brown with dormant grass and all the trees of the forest are alive with the many colours of fall
season/winter = is cold and desolate. The trees are barren and leafless

--[ precip ]--

This is one of the trickier ones. A string is to be returned ONLY if there is precipitation of any kind.

desc/precip:{with:precip,{weather:precip},{if:{not:{eq:{&precip},none}},Right now {prop:precip/{&precip}} {prop:force/{weather:prate}}}}
Since we use the {weather:precip} value twice, it seemed reasonable to make it a variable using "{with"
Here's the precipitation type...

precip/rain = it is raining
precip/hail = hail falls from the sky mixed with rain
precip/sleet = sleet falls from the sky mixed with rain
precip/snow = it is snowing

and this describes how hard its falling

force/0 = almost unnoticeably.
force/1 = in a mist.
force/2 = very lightly.
Force/3 = steadily.
Force/4 = in a forceful storm.

The 'force/0' property is probably unnecessary but for some reason its in the Narnia example. If {weather:prate} = '0' then {weather:precip} should be 'none'. A reminder... All numeric weather values are stored as strings so if you use MUF to read weather properties you'll need to do an 'atoi' before using numeric

--[ sky ]-- ( finally the sky is described )

This is the most complicated one but hopefully you're up to it

desc/sky = Above you the {exec:sky/{weather:daytime}}

sky/dawn = dawn sky {exec:desc/clouds}.
sky/sunrise = dawn sky {exec:desc/clouds}.
sky/morning = morning sky {exec:desc/clouds}.
sky/afternoon = afternoon sky {exec:desc/clouds}.
sky/dusk = dusk sky {exec:desc/clouds}.{exec:desc/dusk-stars}
sky/sunset = dusk sky {exec:desc/clouds}.{exec:desc/dusk-stars}
sky/night = night sky {exec:desc/clouds}.{exec:desc/night-stars}

Evaluate different clouds for different sky conditions

desc/clouds = {exec:clouds/{weather:sky}}

clouds/clear = is clear {exec:skycolor/{weather:daytime}}
clouds/some_clouds = has a few {exec:cloudcolor} clouds drifting by
clouds/cloudy = is nearly covered with a blanket of {exec:cloudcolor} clouds
clouds/overcast = is dark and ominously overcast

Note, no dawn or dusk below ... skycolor/ props used only if clear skies

skycolor/sunrise = and coloured golden brown by the rising sun
skycolor/morning = with the sun shining radiantly
skycolor/afternoon = with the sun shining radiantly
skycolor/sunset = and a glow with the setting sun
skycolor/night = with the heavens in clear view

Eg set the cloud colour to 'white' if no precipitation, 'dark' otherwise

cloudcolor = {if:{eq:{weather:precip},none},white,dark}

I've introduced these MPI macros below because they seem to be rather useful for conditions which come up from time to time.

_msgmacs/visible_sky?:{or:{eq:{weather:sky},clear}, {eq:{weather:sky},
some_clouds}}

This first one simply checks to see if you can see the sky

_msgmacs/phase: {sublist:{weather:moon},1,1, }
This give just the first word in the 'moon' property, deleting the 'waxing' or 'waning' string... possible values: new, crescent, quarter, gibbous, full

Below is where we use these _msgmacs MPI macros

desc/dusk-stars ={if:{visible_sky?},{lit: }As you look up you can just make out the first stars of the evening {exec:moon/{phase}}

desc/night-stars ={if:{visible_sky?},{lit: }In the evening sky you see the stars twinkling {exec:moon/{phase}}

moon/new = and a tiny crescent sliver of a new moon.
moon/crescent = and a crescent moon shines.
Moon/quarter = and a quarter moon.
Moon/gibbous = and a bright moon that is nearly full.
Moon/full = and a full moon shines brightly.

This example is based on NarniaMUSH's weather system. Brazilian Dream's weather system has an additional property which might be useful here. Since the moon is only out part of the time you can use {weather:moonstat} to see if the moon is up, where [roughly] in the sky it is, or if its obscured by the sun or clouds.

--[ Finally, an example of what this look like all put together ]--

A Meadow in the Forest with a Stream
You stand in a meadow amidst a forest. The surrounding trees are thick and form a large clearing that is criss-crossed by a few animal paths. Through the centre of the meadow, a brook runs through with a small waterfall that is roaring softly as it falls over some rocks. The sounds of many animals can be heard as they begin their daily tasks. The air is quite chilly and occasional gusts of wind blow through the meadow. It is fall and the meadow is brown with dormant grass and all the trees of the forest are alive with the many colours of fall. Above you the morning sky is clear blue with the sun shining radiantly.

Hopefully this example shows you some of the things you can do with the MUCK weather system's MPI routine.