Had some time to putz around with a prototype of doing a weather api w/ AresMush.
It’s nothing spectacular right now, it just returns the weather in my home town. But it’s a start. I am thinking
you can have different areas setup in the config, ie, Denver, Miami, etc, with their zip code, or GPS coordinates and it will fetch the live data.
Right now it will do an api call every time you type openweather. Thinking caching it on the hour, so the game cron will trigger it.
Let me know if you guys/gals have any ideas you like to see. I’m new to Ruby, and coding for ares, so any tips/advice is welcome.
That’s cool. I know there have been a couple games interested in real-world weather, so I hope you’d consider submitting it as an official Ares Extra once it’s more fleshed out.
FYI Ares does have some rest connector stuff built in (RestConnector class in the engine), so you could potentially remove the dependency on the outside rest-client gem. That would make it easier for folks to plug it into their games without having to modify their Ares gemfile.
Thanks, I removed the rest-client dependency after peeping at the RestConnector class. Thank you for the suggestions! I’ll defiantly submitted to Extras once it’s gets hammered out.
Ok. I’ll give this a shot. I have peek into how Ares weather currently works and make it similar. Just starting out with Ruby/Ares Coding. I’ll let ya’ll know when I have another milestone.
Made some more progress today! The openweather command will pull api data for areas you define in the config file. The descriptions are a bit short, and will be expanded on
+==~~~~~====~~~~====~~~~====~~~~=====~~~~=====~~~~====~~~~====~~~~====~~~~~==+
Polar:
It is a -72.75 summer night. The weather is broken clouds.
Vegas:
It is a 91.38 summer night. The weather is clear sky.
Default:
It is a 95.23 summer night. The weather is shower rain.
+==~~~~~====~~~~====~~~~====~~~~=====~~~~=====~~~~====~~~~====~~~~====~~~~~==+
Here is the config file example
---
openweather:
api_key: Your API Key
units: imperial
shortcuts: {}
# use either zip or lat/long coordinates
default_climate:
zip: 78132
climate_for_area:
Offstage: none
Polar:
coords:
lon: 40.92
lat: -74.7
Vegas:
zip: 89109
In my advanced wishlist, I’d love if we had a list of the possible weathers it can pull, and then the ability to config descriptions for that status. So ‘clear sky’ can say ‘The sky is clear, with not a cloud in sight’. Or some such.
The api will return a code, a main weather type, and short description.
How does it sound if we put in the config file a list of return codes, and longer description? Something like below in the config.yml
weather_code_desc:
602: A heavy snowfall makes it difficult to see far.
615: A mix of light rain and snow falls from above.
800: The sky is clear, with not a cloud in sight.
Here is a big milestone update. Example places below.
I think all is left is to tie it into room descriptions. I think this hooks in from room_desc_builder.rb in /aresmush/plugins/describe. The cron functionality is in and working, and custom descriptions are also set.
Polar:
It is -57.65°F with a humidity of 93% on this summer morning. There are 12.95 mph winds from the south southeast. Broken clouds float in the clear sky.
Vegas:
It is 61.27°F with a humidity of 33% on this summer morning. There are 3.96 mph winds from the north northeast. Broken clouds float in the clear sky.
Grand Lake:
It is 42.66°F with a humidity of 68% on this summer morning. There are 4.7 mph winds from the south southeast. The sky is clear, with not a cloud in sight.
Rocky Mountain National Park:
It is 46°F with a humidity of 65% on this summer morning. There are 5.55 mph winds from the south. The sky is clear, with not a cloud in sight.
Granby:
It is 40.5°F with a humidity of 68% on this summer morning. There are 4.7 mph winds from the south southeast. The sky is clear, with not a cloud in sight.
Sahara Desert:
It is 91.39°F with a humidity of 15% on this summer morning. There are 14.74 mph winds from the north northeast. The sky is clear, with not a cloud in sight.
Grand Rapids:
It is 67.35°F with a humidity of 93% on this summer morning. There are 3.36 mph winds from the southeast. It is misty. The air is thick with moisture, and there's just barely a light rain.
Greenland:
It is 0.49°F with a humidity of 92% on this summer morning. There are 10.94 mph winds from the southwest. Broken clouds float in the clear sky.
Default:
It is 76.14°F with a humidity of 88% on this summer morning. There are 10.54 mph winds from the south southeast. It is misty. The air is thick with moisture, and there's just barely a light rain.
+==~~~~~====~~~~====~~~~====~~~~=====~~~~=====~~~~====~~~~====~~~~====~~~~~==+
Tying into the room descs will require people manually changing the room desc builder when they install your extra plugin. So you can just include those instructions in your README setup file. There’s no clean/reliable way to automatically patch that with an extra install unfortunately.