Date, Time, and Weather (work in progress)

K.V.

So, Anonynn asked something in a different thread, and I got a little crazy while playing around with what I learned while trying to help.

http://textadventures.co.uk/games/view/yfl6ohdto0il_0l_hj0ggg/date-and-weather-and-stuff

(It works in the desktop player, but it only works halfway in the web player.)


The code:

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Date and Weather and stuff">
    <gameid>113ae923-f8a2-4b92-a4a6-1af36ab0ba4c</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
    <feature_annotations />
    <attr name="feature_advancedwearables" type="boolean">false</attr>
    <feature_advancedscripts />
    <start type="script"><![CDATA[
      calendar.weatherCodeDict = NewStringDictionary()
      dictionary add (calendar.weatherCodeDict, "0", "tornado")
      dictionary add (calendar.weatherCodeDict, "1", "tropical storm")
      dictionary add (calendar.weatherCodeDict, "2", "hurricane")
      dictionary add (calendar.weatherCodeDict, "3", "severe thunderstorms")
      dictionary add (calendar.weatherCodeDict, "4", "thunderstorms")
      dictionary add (calendar.weatherCodeDict, "5", "mixed rain and snow")
      dictionary add (calendar.weatherCodeDict, "6", "mixed rain and sleet")
      dictionary add (calendar.weatherCodeDict, "7", "mixed snow and sleet")
      dictionary add (calendar.weatherCodeDict, "8", "freezing drizzle")
      dictionary add (calendar.weatherCodeDict, "9", "drizzle")
      dictionary add (calendar.weatherCodeDict, "10", "freezing rain")
      dictionary add (calendar.weatherCodeDict, "11", "showers")
      dictionary add (calendar.weatherCodeDict, "12", "showers")
      dictionary add (calendar.weatherCodeDict, "13", "snow flurries")
      dictionary add (calendar.weatherCodeDict, "14", "light snow showers")
      dictionary add (calendar.weatherCodeDict, "15", "blowing snow")
      dictionary add (calendar.weatherCodeDict, "16", "snow")
      dictionary add (calendar.weatherCodeDict, "17", "hail")
      dictionary add (calendar.weatherCodeDict, "18", "sleet")
      dictionary add (calendar.weatherCodeDict, "19", "dust")
      dictionary add (calendar.weatherCodeDict, "20", "foggy")
      dictionary add (calendar.weatherCodeDict, "21", "haze")
      dictionary add (calendar.weatherCodeDict, "22", "smoky")
      dictionary add (calendar.weatherCodeDict, "23", "blustery")
      dictionary add (calendar.weatherCodeDict, "24", "windy")
      dictionary add (calendar.weatherCodeDict, "25", "cold")
      dictionary add (calendar.weatherCodeDict, "26", "cloudy")
      dictionary add (calendar.weatherCodeDict, "27", "mostly cloudy")
      dictionary add (calendar.weatherCodeDict, "28", "mostly cloudy")
      dictionary add (calendar.weatherCodeDict, "29", "partly cloudy")
      dictionary add (calendar.weatherCodeDict, "30", "partly cloudy")
      dictionary add (calendar.weatherCodeDict, "31", "clear")
      dictionary add (calendar.weatherCodeDict, "32", "sunny")
      dictionary add (calendar.weatherCodeDict, "33", "fair")
      dictionary add (calendar.weatherCodeDict, "34", "fair")
      dictionary add (calendar.weatherCodeDict, "35", "mixed rain and hail")
      dictionary add (calendar.weatherCodeDict, "36", "hot")
      dictionary add (calendar.weatherCodeDict, "37", "isolated thunderstorms")
      dictionary add (calendar.weatherCodeDict, "38", "scattered thunderstorms")
      dictionary add (calendar.weatherCodeDict, "39", "scattered thunderstorms")
      dictionary add (calendar.weatherCodeDict, "40", "scattered showers")
      dictionary add (calendar.weatherCodeDict, "41", "heavy snow")
      dictionary add (calendar.weatherCodeDict, "42", "scattered snow showers")
      dictionary add (calendar.weatherCodeDict, "43", "heavy snow")
      dictionary add (calendar.weatherCodeDict, "44", "partly cloudy")
      dictionary add (calendar.weatherCodeDict, "45", "thundershowers")
      dictionary add (calendar.weatherCodeDict, "46", "snow showers")
      dictionary add (calendar.weatherCodeDict, "47", "isolated thundershowers")
      dictionary add (calendar.weatherCodeDict, "3200", "not available")
      // JS.eval (js_room.description)
      JS.eval ("var today = new Date();var dd = today.getDate();var mm = today.getMonth()+1;var yyyy = today.getFullYear();var hrs = today.getHours();var mins = today.getMinutes();var secs = today.getSeconds();ASLEvent('SetHours',hrs);ASLEvent('SetMinutes',mins);if(dd<10) {	dd = '0'+dd} if(mm<10) {	mm = '0'+mm} today = mm + '/' + dd + '/' + yyyy;if(hrs>12) {	ampm = 'pm';	hrs = '0' + '' + hrs - 12}else{	ampm = 'am'} if (mins<10) {	mins = '0'+mins} if(secs<10) {secs = '0' + secs}time = hrs + ':' + mins + ':' + secs + ' ' + ampm;ASLEvent('SetDate',today);ASLEvent('SetTime',time);ASLEvent('SetYear',yyyy);ASLEvent('SetMonth',mm);ASLEvent('SetDay',dd);if(mm==12&&(dd>27&&dd<=31)){ASLEvent('SetHoliday','newYears');};")
    ]]></start>
    <inituserinterface type="script">
    </inituserinterface>
    <object name="startupRoom">
      <inherit name="editor_room" />
      <enter type="script">
        ClearScreen
        msg ("Please enter the name of the city in which you are currently located.")
        get input {
          SetCityManually (result)
          msg ("Setting city to "+result+".")
          JS.eval (js_room.description)
          SetTimeout (2) {
            JS.loadWeather (calendar.playerCity)
          }
          SetTimeout (4) {
            ClearScreen
            MoveObject (game.pov, room)
            JS.loadWeather (calendar.playerCity)
          }
        }
      </enter>
      <object name="player">
        <inherit name="editor_object" />
        <inherit name="editor_player" />
      </object>
    </object>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <description><![CDATA[<hr/><br/>Today is {calendar.month}-{calendar.day}-{calendar.year}.<br/><hr/><br/><br/>It is {calendar.tempF}&deg;F and {=WeatherStatus(calendar.weatherCode)} outside!{if calendar.isHoliday:<br/><br/>{=HolidayMessage(calendar.holiday)}}<br/><br/><div id='weather'></div>]]></description>
    <enter type="script"><![CDATA[
      JS.eval ("if(mm == 10 && (15 < dd && dd < 31)){alert('CHECK!');};")
    ]]></enter>
    <object name="letter">
      <inherit name="editor_object" />
      <look><![CDATA[It's a letter, dated {calendar.month}/{=ToInt(calendar.day)-2}/{calendar.year}.<br/><br/>(You could try {command:read letter:reading} it.)]]></look>
      <read><![CDATA[{either letter.parent=game.pov:You have until 11:59 {if calendar.hoursJS<10:a}{if calendar.hoursJS>10:p}m on {calendar.month}/{calendar.day}/{calendar.year} to email the author to receive your secret command!  (Enter {command:CONTACT} for the link!).|You can't read something you're not holding.}]]></read>
      <take />
    </object>
    <exit alias="in" to="another room">
      <inherit name="indirection" />
    </exit>
  </object>
  <object name="calendar">
    <inherit name="editor_object" />
    <holidays type="stringdictionary">
      <item>
        <key>valentines</key>
        <value>Insert Valentine's Day message here!</value>
      </item>
      <item>
        <key>easter</key>
        <value>INSERT EASTER EGGS ALERT HERE!</value>
      </item>
      <item>
        <key>stPatricks</key>
        <value>INSERT SAINT PATRICK'S DAY MESSAGE!</value>
      </item>
      <item>
        <key>hallowsShroud</key>
        <value>INSERT HALLOW'S SHROUD MESSAGE</value>
      </item>
      <item>
        <key>christmas</key>
        <value>INSERT XMAS MESSAGE</value>
      </item>
      <item>
        <key>newYears</key>
        <value>We hope you have a happy and safe new year!</value>
      </item>
    </holidays>
    <isHoliday type="boolean">false</isHoliday>
    <holiday type="string"></holiday>
  </object>
  <object name="another room">
    <inherit name="editor_room" />
    <description><![CDATA[This room is pointless.<br/><br/>{command:out:Go back to the first room.}]]></description>
    <enter type="script">
    </enter>
    <exit alias="out" to="room">
      <inherit name="outdirection" />
    </exit>
  </object>
  <object name="js_room">
    <inherit name="editor_room" />
    <description><![CDATA[/*! simpleWeather v3.1.0 - http://simpleweatherjs.com */!function(t){"use strict";function e(t,e){return"f"===t?Math.round(5/9*(e-32)):Math.round(1.8*e+32)}t.extend({simpleWeather:function(i){i=t.extend({location:"",woeid:"",unit:"f",success:function(t){},error:function(t){}},i);var o=new Date,n="https://query.yahooapis.com/v1/public/yql?format=json&rnd="+o.getFullYear()+o.getMonth()+o.getDay()+o.getHours()+"&diagnostics=true&callback=?&q=";if(""!==i.location){var r="";r=/^(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)$/.test(i.location)?"("+i.location+")":i.location,n+='select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="'+r+'") and u="'+i.unit+'"'}else{if(""===i.woeid)return i.error("Could not retrieve weather due to an invalid location."),!1;n+="select * from weather.forecast where woeid="+i.woeid+' and u="'+i.unit+'"'}return t.getJSON(encodeURI(n),function(t){if(null!==t&&null!==t.query&&null!==t.query.results&&"Yahoo! Weather Error"!==t.query.results.channel.description){var o,n=t.query.results.channel,r={},s=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW","N"],a="https://s.yimg.com/os/mit/media/m/weather/images/icons/l/44d-100567.png";r.title=n.item.title,r.temp=n.item.condition.temp,r.code=n.item.condition.code,r.todayCode=n.item.forecast[0].code,r.currently=n.item.condition.text,r.high=n.item.forecast[0].high,r.low=n.item.forecast[0].low,r.text=n.item.forecast[0].text,r.humidity=n.atmosphere.humidity,r.pressure=n.atmosphere.pressure,r.rising=n.atmosphere.rising,r.visibility=n.atmosphere.visibility,r.sunrise=n.astronomy.sunrise,r.sunset=n.astronomy.sunset,r.description=n.item.description,r.city=n.location.city,r.country=n.location.country,r.region=n.location.region,r.updated=n.item.pubDate,r.link=n.item.link,r.units={temp:n.units.temperature,distance:n.units.distance,pressure:n.units.pressure,speed:n.units.speed},r.wind={chill:n.wind.chill,direction:s[Math.round(n.wind.direction/22.5)],speed:n.wind.speed},n.item.condition.temp<80&&n.atmosphere.humidity<40?r.heatindex=-42.379+2.04901523*n.item.condition.temp+10.14333127*n.atmosphere.humidity-.22475541*n.item.condition.temp*n.atmosphere.humidity-6.83783*Math.pow(10,-3)*Math.pow(n.item.condition.temp,2)-5.481717*Math.pow(10,-2)*Math.pow(n.atmosphere.humidity,2)+1.22874*Math.pow(10,-3)*Math.pow(n.item.condition.temp,2)*n.atmosphere.humidity+8.5282*Math.pow(10,-4)*n.item.condition.temp*Math.pow(n.atmosphere.humidity,2)-1.99*Math.pow(10,-6)*Math.pow(n.item.condition.temp,2)*Math.pow(n.atmosphere.humidity,2):r.heatindex=n.item.condition.temp,"3200"==n.item.condition.code?(r.thumbnail=a,r.image=a):(r.thumbnail="https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+n.item.condition.code+"ds.png",r.image="https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+n.item.condition.code+"d.png"),r.alt={temp:e(i.unit,n.item.condition.temp),high:e(i.unit,n.item.forecast[0].high),low:e(i.unit,n.item.forecast[0].low)},"f"===i.unit?r.alt.unit="c":r.alt.unit="f",r.forecast=[];for(var m=0;m<n.item.forecast.length;m++)o=n.item.forecast[m],o.alt={high:e(i.unit,n.item.forecast[m].high),low:e(i.unit,n.item.forecast[m].low)},"3200"==n.item.forecast[m].code?(o.thumbnail=a,o.image=a):(o.thumbnail="https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+n.item.forecast[m].code+"ds.png",o.image="https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+n.item.forecast[m].code+"d.png"),r.forecast.push(o);i.success(r)}else i.error("There was a problem retrieving the latest weather information.")}),this}})}(jQuery);function loadWeather(location, woeid) {  $.simpleWeather({    location: location,    woeid: woeid,    unit: 'f',    success: function(weather) {      ASLEvent('SetTempF',weather.temp);ASLEvent('SetCityFromWeather',weather.city);ASLEvent('SetWeatherCode',weather.code);ASLEvent('SetTempCelsius',weather.alt.temp);setTimeout(function(){html = '<h2><i class="icon-'+weather.code+'"></i> '+weather.temp+'&deg;'+weather.units.temp+'</h2>';      html += '<ul><li>'+weather.city+', '+weather.region+'</li>';      html += '<li class="currently">'+weather.currently+'</li>';      html += '<li>'+weather.alt.temp+'&deg;C</li></ul>';              $('#weather').html(html); },500);   },    error: function(error) {      alert('error with weather');      $("#weather").html('<p>'+error+'</p>');  }  });};]]></description>
    <attr name="implementation_notes"><![CDATA[simpleWeather.js<br/><br/>MIT license<br/><br/>----------------------------------------------------------------------------------<br/><br/>Copyright (c) 2016 James Fleeting, http://jamesfleeting.com/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
                    ]]></attr>
  </object>
  <command name="contact">
    <pattern>contact;contacts;email;message;bug;report;issue</pattern>
    <script>
      DisplayMailtoLink ("[email protected]", "[email protected]")
    </script>
  </command>
  <function name="SetMonth" parameters="month">
    calendar.month = month
  </function>
  <function name="HolidayMessage" parameters="holiday" type="string">
    return (StringDictionaryItem(calendar.holidays,holiday))
  </function>
  <function name="SetHoliday" parameters="holiday">
    calendar.isHoliday = true
    calendar.holiday = holiday
  </function>
  <function name="SetDay" parameters="day">
    calendar.day = day
  </function>
  <function name="SetTempF" parameters="temp">
    calendar.tempF = temp
  </function>
  <function name="SetWeatherCode" parameters="weatherCode">
    calendar.weatherCode = weatherCode
  </function>
  <function name="SetCityFromWeather" parameters="city">
    calendar.weatherCity = city
  </function>
  <function name="SetTempCelsius" parameters="tempCelsius">
    calendar.tempC = tempCelsius
  </function>
  <function name="WeatherStatus" parameters="code" type="string">
    status = StringDictionaryItem(calendar.weatherCodeDict,code)
    return (status)
  </function>
  <function name="SetCityManually" parameters="city">
    calendar.playerCity = city
  </function>
  <function name="SetYear" parameters="year">
    calendar.year = year
  </function>
  <function name="SetDate" parameters="date">
    calendar.dateAsString = date
  </function>
  <function name="SetTime" parameters="time">
    calendar.timeJS = time
  </function>
  <function name="SetHours" parameters="hrs">
    calendar.hoursJS = ToInt(hrs)
  </function>
  <function name="SetMinutes" parameters="min">
    calendar.minutesJS = ToInt(min)
  </function>
</asl>

image



Something in the room description throws an error in the web player for some reason. (It may be the text processor (I have it evaluating functions that return strings from dictionaries), but that's just a wild guess.)


SCREENSHOT OF DESKTOP PLAYER:


image


SCREENSHOT OF ONLINE PLAY:


https://screenshots.firefoxusercontent.com/images/d18898da-2c4e-4152-9856-6cde195edca1.png


K.V.

It didn't fix it when I changed it from the text-processor stuff to a normal msg. I get the same error online, but not in the desktop player (just like before).

This makes me think it might have something to do with loading time at startup?


Error running script: Error compiling expression 'StringDictionaryItem(calendar.weatherCodeDict,code)': FunctionCallElement: Could find not function 'StringDictionaryItem(QuestDictionary`1; Object)'

Does that mean it couldn't find the dictionary, or the parameter was null? (I'm thinking the parameter was null.)


That is pretty cool.

Does that mean it couldn't find the dictionary, or the parameter was null? (I'm thinking the parameter was null.)

The C# code that generated this message calls null "Object", so you are right.

It might be worth calling WeatherStatus before printing the room description; it could be that it gets called later as it is embedding in the strng for the text processor. Or is that what you meant by "It didn't fix it when I changed it from the text-processor stuff to a normal msg"?

Might be useful putting a message in SetWeatherCode to see when it gets called, and with what value.


K.V.

Thank you, thank you.

I thought it sounded pretty cool when Anonynn asked about it.


It's the date that's not getting set. (I was thinking I was overloading the web player by calling a function that returned a string from a dictionary via the text-processor, but nope.)

Hrmm...

I shall nap, then come back and fix this.


K.V.

Okay, I finally got it working online.

http://textadventures.co.uk/games/view/yfl6ohdto0il_0l_hj0ggg/date-and-weather-and-stuff


@Anonynn

This bud's code's for you!


Here's the code:

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Date, Time, and Weather (and stuff)">
    <gameid>22ec145c-169f-4b9d-ae36-454f0d79af03</gameid>
    <version>0.0.20</version>
    <firstpublished>2017</firstpublished>
    <feature_annotations />
    <feature_advancedscripts />
    <author>KV</author>
    <start type="script">
      JS.eval (js.description)
      JS.setupDateAndTime ()
      SetTimeout (2) {
        JS.setupDateAndTime ()
      }
    </start>
    <description>This is just an example game.</description>
    <object name="startupRoom">
      <inherit name="editor_room" />
      <usedefaultprefix type="boolean">false</usedefaultprefix>
      <alias>ENTER YOUR CITY</alias>
      <enter type="script">
        JS.eval ("$('#txtCommandDiv').show();")
        ClearScreen
        msg ("Please enter the name of the city in which you are currently located.")
        get input {
          SetCityManually (result)
          JS.eval ("$('#txtCommand').hide();")
          OutputTextNoBr ("Setting city to "+result+".")
          SetTimeout (2) {
            // JS.eval (js_room.description)
          }
          SetTimeout (4) {
            JS.loadWeather (calendar.playerCity)
          }
          SetTimeout (6) {
            JS.eval ("$('#txtCommand').show();")
            ClearScreen
            MoveObject (game.pov, room)
            JS.loadWeather (calendar.playerCity)
          }
          TextFX_Typewriter (".....", 950)
        }
      </enter>
    </object>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <description type="script"><![CDATA[
      msg ("<hr/><br/>Today is "+calendar.month+"-"+calendar.day+"-"+calendar.year+".<br/><hr/><br/><br/>It is "+calendar.tempF+"&deg;F and "+WeatherStatus(calendar.weatherCode)+" outside!")
      if (IsHoliday()) {
        msg ("<br/><br/>"+HolidayMessage(calendar.holiday)+"<br/><br/>")
      }
      msg ("<div id='weather'></div>")
    ]]></description>
    <enter type="script">
    </enter>
    <object name="letter">
      <inherit name="editor_object" />
      <look><![CDATA[It's a letter, dated {calendar.month}/{=ToInt(calendar.day)-2}/{calendar.year}.<br/><br/>(You could try {command:read letter:reading} it.)]]></look>
      <read><![CDATA[{either letter.parent=game.pov:You have until 11:59 {if calendar.hoursJS<10:a}{if calendar.hoursJS>10:p}m on {calendar.month}/{calendar.day}/{calendar.year} to email the author to receive your secret command!  (Enter {command:CONTACT} for the link!).|You can't read something you're not holding.}]]></read>
      <take />
      <inventoryverbs type="stringlist">
        <value>Look at</value>
        <value>Drop</value>
      </inventoryverbs>
    </object>
    <exit alias="in" to="another room">
      <inherit name="indirection" />
    </exit>
  </object>
  <object name="calendar">
    <inherit name="editor_object" />
    <holidays type="stringdictionary">
      <item>
        <key>valentines</key>
        <value>Insert Valentine's Day message here!</value>
      </item>
      <item>
        <key>easter</key>
        <value>INSERT EASTER EGGS ALERT HERE!</value>
      </item>
      <item>
        <key>stPatricks</key>
        <value>INSERT SAINT PATRICK'S DAY MESSAGE!</value>
      </item>
      <item>
        <key>hallowsShroud</key>
        <value>INSERT HALLOW'S SHROUD MESSAGE</value>
      </item>
      <item>
        <key>christmas</key>
        <value>INSERT XMAS MESSAGE</value>
      </item>
      <item>
        <key>newYears</key>
        <value>We hope you have a happy and safe new year!</value>
      </item>
      <item>
        <key>earthday</key>
        <value>INSERT EARTH DAY MESSAGE!</value>
      </item>
    </holidays>
    <isHoliday type="boolean">false</isHoliday>
    <holiday type="string"></holiday>
    <weatherCodeDict type="stringdictionary">
      <item>
        <key>0</key>
        <value>you need to take shelter because there is a tornado</value>
      </item>
      <item>
        <key>1</key>
        <value>you need to take shelter because there is a tropical storm</value>
      </item>
      <item>
        <key>2</key>
        <value>you need to take shelter because there is a hurricane</value>
      </item>
      <item>
        <key>3</key>
        <value>there are severe thunderstorms</value>
      </item>
      <item>
        <key>4</key>
        <value>there are thunderstorms</value>
      </item>
      <item>
        <key>5</key>
        <value>mixed rain and snow</value>
      </item>
      <item>
        <key>6</key>
        <value>mixed rain and sleet</value>
      </item>
      <item>
        <key>7</key>
        <value>mixed snow and sleet</value>
      </item>
      <item>
        <key>8</key>
        <value>there is freezing drizzle</value>
      </item>
      <item>
        <key>9</key>
        <value>there is drizzle</value>
      </item>
      <item>
        <key>10</key>
        <value>there is freezing rain</value>
      </item>
      <item>
        <key>11</key>
        <value>there are showers</value>
      </item>
      <item>
        <key>12</key>
        <value>there are showers</value>
      </item>
      <item>
        <key>13</key>
        <value>there are snow flurries</value>
      </item>
      <item>
        <key>14</key>
        <value>there are light snow showers</value>
      </item>
      <item>
        <key>15</key>
        <value>there is blowing snow</value>
      </item>
      <item>
        <key>16</key>
        <value>there is snow</value>
      </item>
      <item>
        <key>17</key>
        <value>there is hail</value>
      </item>
      <item>
        <key>18</key>
        <value>there is sleet</value>
      </item>
      <item>
        <key>19</key>
        <value>there is dust</value>
      </item>
      <item>
        <key>20</key>
        <value>foggy</value>
      </item>
      <item>
        <key>21</key>
        <value>there is haze</value>
      </item>
      <item>
        <key>22</key>
        <value>smoky</value>
      </item>
      <item>
        <key>23</key>
        <value>blustery</value>
      </item>
      <item>
        <key>24</key>
        <value>windy</value>
      </item>
      <item>
        <key>25</key>
        <value>cold</value>
      </item>
      <item>
        <key>26</key>
        <value>cloudy</value>
      </item>
      <item>
        <key>27</key>
        <value>mostly cloudy</value>
      </item>
      <item>
        <key>28</key>
        <value>mostly cloudy</value>
      </item>
      <item>
        <key>29</key>
        <value>partly cloudy</value>
      </item>
      <item>
        <key>30</key>
        <value>partly cloudy</value>
      </item>
      <item>
        <key>31</key>
        <value>clear</value>
      </item>
      <item>
        <key>32</key>
        <value>sunny</value>
      </item>
      <item>
        <key>33</key>
        <value>fair</value>
      </item>
      <item>
        <key>34</key>
        <value>fair</value>
      </item>
      <item>
        <key>35</key>
        <value>there is mixed rain and hail</value>
      </item>
      <item>
        <key>36</key>
        <value>it is hot</value>
      </item>
      <item>
        <key>37</key>
        <value>there are isolated thunderstorms</value>
      </item>
      <item>
        <key>38</key>
        <value>there are scattered thunderstorms</value>
      </item>
      <item>
        <key>39</key>
        <value>there are scattered thunderstorms</value>
      </item>
      <item>
        <key>40</key>
        <value>there are scattered showers</value>
      </item>
      <item>
        <key>41</key>
        <value>there is heavy snow</value>
      </item>
      <item>
        <key>42</key>
        <value>there are scattered snow showers</value>
      </item>
      <item>
        <key>43</key>
        <value>there is heavy snow</value>
      </item>
      <item>
        <key>44</key>
        <value>partly cloudy</value>
      </item>
      <item>
        <key>45</key>
        <value>there are thundershowers</value>
      </item>
      <item>
        <key>46</key>
        <value>there are snow showers</value>
      </item>
      <item>
        <key>47</key>
        <value>there are isolated thundershowers</value>
      </item>
      <item>
        <key>3200</key>
        <value>not available</value>
      </item>
    </weatherCodeDict>
    <hoursJS type="int">4</hoursJS>
    <minutesJS type="int">20</minutesJS>
    <dateAsString>4/20/2017</dateAsString>
    <timeJS>4:20:00 am</timeJS>
    <year>2017</year>
    <month>4</month>
    <day>20</day>
    <playerCity>NOT SET UP</playerCity>
    <tempF>26</tempF>
    <weatherCity>NOT SET UP</weatherCity>
    <weatherCode>29</weatherCode>
    <tempC>-3</tempC>
    <holidayDates type="stringdictionary">
      <item>
        <key>214</key>
        <value>valentines</value>
      </item>
      <item>
        <key>420</key>
        <value>earthday</value>
      </item>
      <item>
        <key>1229</key>
        <value>newYears</value>
      </item>
      <item>
        <key>1230</key>
        <value>newYears</value>
      </item>
      <item>
        <key>1231</key>
        <value>newYears</value>
      </item>
      <item>
        <key>11</key>
        <value>newYears</value>
      </item>
    </holidayDates>
    <monthDict type="stringdictionary">
      <item>
        <key>1</key>
        <value>January</value>
      </item>
      <item>
        <key>2</key>
        <value>February</value>
      </item>
      <item>
        <key>3</key>
        <value>March</value>
      </item>
      <item>
        <key>4</key>
        <value>April</value>
      </item>
      <item>
        <key>5</key>
        <value>May</value>
      </item>
      <item>
        <key>6</key>
        <value>June</value>
      </item>
      <item>
        <key>7</key>
        <value>July</value>
      </item>
      <item>
        <key>8</key>
        <value>August</value>
      </item>
      <item>
        <key>9</key>
        <value>September</value>
      </item>
      <item>
        <key>10</key>
        <value>October</value>
      </item>
      <item>
        <key>11</key>
        <value>November</value>
      </item>
      <item>
        <key>12</key>
        <value>December</value>
      </item>
    </monthDict>
  </object>
  <object name="another room">
    <inherit name="editor_room" />
    <description><![CDATA[This room is pointless.<br/><br/>{command:out:Go back to the first room.}]]></description>
    <enter type="script">
      IsHoliday
    </enter>
    <exit alias="out" to="room">
      <inherit name="outdirection" />
    </exit>
  </object>
  <command name="contact">
    <pattern>contact;contacts;email;message;bug;report;issue</pattern>
    <script>
      DisplayMailtoLink ("[email protected]", "[email protected]")
    </script>
  </command>
  <object name="Loading Screen">
    <inherit name="editor_room" />
    <usedefaultprefix type="boolean">false</usedefaultprefix>
    <beforeenter type="script">
      JS.eval ("$('#txtCommandDiv').hide();")
    </beforeenter>
    <enter type="script">
      ClearScreen
      SetTimeout (5) {
        MoveObject (game.pov, startupRoom)
      }
      OutputTextNoBr ("Loading")
      TextFX_Typewriter (".....", 550)
    </enter>
    <onexit type="script">
    </onexit>
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
  </object>
  <command name="secret_command">
    <script>
      msg ("Don't forget to drink your Ovaltine!")
    </script>
    <pattern>secret command;secret</pattern>
  </command>
  <object name="js">
    <inherit name="editor_room" />
    <description><![CDATA[setupDateAndTime = function(){var today = new Date();var dd = today.getDate();var mm = today.getMonth()+1;var yyyy = today.getFullYear();var hrs = today.getHours();var mins = today.getMinutes();var secs = today.getSeconds();var ampm = 'am';var hrsMins = [hrs,mins];if(dd<10) { dd = '0'+dd} if(mm<10) { mm = '0'+mm} today = mm + '/' + dd + '/' + yyyy;if(hrs>12) { ampm = 'pm'; hrs = '0' + '' + hrs - 12}else{ ampm = 'am'} if (mins<10) { mins = '0'+mins} if(secs<10) {secs = '0' + secs}time = hrs + ':' + mins + ':' + secs + ' ' + ampm;var realHrs = hrsMins[0];var realMins = hrsMins[1];var param = realHrs+';'+realMins+';'+time+';'+today+';'+yyyy+';'+mm+';'+dd;ASLEvent('BreakDateDown',param);};/*! simpleWeather v3.1.0 - http://simpleweatherjs.com */!function(t){"use strict";function e(t,e){return"f"===t?Math.round(5/9*(e-32)):Math.round(1.8*e+32)}t.extend({simpleWeather:function(i){i=t.extend({location:"",woeid:"",unit:"f",success:function(t){},error:function(t){}},i);var o=new Date,n="https://query.yahooapis.com/v1/public/yql?format=json&rnd="+o.getFullYear()+o.getMonth()+o.getDay()+o.getHours()+"&diagnostics=true&callback=?&q=";if(""!==i.location){var r="";r=/^(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)$/.test(i.location)?"("+i.location+")":i.location,n+='select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="'+r+'") and u="'+i.unit+'"'}else{if(""===i.woeid)return i.error("Could not retrieve weather due to an invalid location."),!1;n+="select * from weather.forecast where woeid="+i.woeid+' and u="'+i.unit+'"'}return t.getJSON(encodeURI(n),function(t){if(null!==t&&null!==t.query&&null!==t.query.results&&"Yahoo! Weather Error"!==t.query.results.channel.description){var o,n=t.query.results.channel,r={},s=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW","N"],a="https://s.yimg.com/os/mit/media/m/weather/images/icons/l/44d-100567.png";r.title=n.item.title,r.temp=n.item.condition.temp,r.code=n.item.condition.code,r.todayCode=n.item.forecast[0].code,r.currently=n.item.condition.text,r.high=n.item.forecast[0].high,r.low=n.item.forecast[0].low,r.text=n.item.forecast[0].text,r.humidity=n.atmosphere.humidity,r.pressure=n.atmosphere.pressure,r.rising=n.atmosphere.rising,r.visibility=n.atmosphere.visibility,r.sunrise=n.astronomy.sunrise,r.sunset=n.astronomy.sunset,r.description=n.item.description,r.city=n.location.city,r.country=n.location.country,r.region=n.location.region,r.updated=n.item.pubDate,r.link=n.item.link,r.units={temp:n.units.temperature,distance:n.units.distance,pressure:n.units.pressure,speed:n.units.speed},r.wind={chill:n.wind.chill,direction:s[Math.round(n.wind.direction/22.5)],speed:n.wind.speed},n.item.condition.temp<80&&n.atmosphere.humidity<40?r.heatindex=-42.379+2.04901523*n.item.condition.temp+10.14333127*n.atmosphere.humidity-.22475541*n.item.condition.temp*n.atmosphere.humidity-6.83783*Math.pow(10,-3)*Math.pow(n.item.condition.temp,2)-5.481717*Math.pow(10,-2)*Math.pow(n.atmosphere.humidity,2)+1.22874*Math.pow(10,-3)*Math.pow(n.item.condition.temp,2)*n.atmosphere.humidity+8.5282*Math.pow(10,-4)*n.item.condition.temp*Math.pow(n.atmosphere.humidity,2)-1.99*Math.pow(10,-6)*Math.pow(n.item.condition.temp,2)*Math.pow(n.atmosphere.humidity,2):r.heatindex=n.item.condition.temp,"3200"==n.item.condition.code?(r.thumbnail=a,r.image=a):(r.thumbnail="https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+n.item.condition.code+"ds.png",r.image="https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+n.item.condition.code+"d.png"),r.alt={temp:e(i.unit,n.item.condition.temp),high:e(i.unit,n.item.forecast[0].high),low:e(i.unit,n.item.forecast[0].low)},"f"===i.unit?r.alt.unit="c":r.alt.unit="f",r.forecast=[];for(var m=0;m<n.item.forecast.length;m++)o=n.item.forecast[m],o.alt={high:e(i.unit,n.item.forecast[m].high),low:e(i.unit,n.item.forecast[m].low)},"3200"==n.item.forecast[m].code?(o.thumbnail=a,o.image=a):(o.thumbnail="https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+n.item.forecast[m].code+"ds.png",o.image="https://s.yimg.com/zz/combo?a/i/us/nws/weather/gr/"+n.item.forecast[m].code+"d.png"),r.forecast.push(o);i.success(r)}else i.error("There was a problem retrieving the latest weather information.")}),this}})}(jQuery);function loadWeather(location, woeid) {  $.simpleWeather({    location: location,    woeid: woeid,    unit: 'f',    success: function(weather) {      ASLEvent('SetTempF',weather.temp);ASLEvent('SetCityFromWeather',weather.city);ASLEvent('SetWeatherCode',weather.code);ASLEvent('SetTempCelsius',weather.alt.temp);setTimeout(function(){html = '<h2><i class="icon-'+weather.code+'"></i> '+weather.temp+'&deg;'+weather.units.temp+'</h2>';      html += '<ul><li>'+weather.city+', '+weather.region+'</li>';      html += '<li class="currently">'+weather.currently+'</li>';      html += '<li>'+weather.alt.temp+'&deg;C</li></ul>';              $('#weather').html(html); },500);   },    error: function(error) {      alert('error with weather');      $("#weather").html('<p>'+error+'</p>');  }  });};]]></description>
    <attr name="implementation_notes"><![CDATA[simpleWeather<br/><br/>Copyright (c) 2016 James Fleeting, http://jamesfleeting.com/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<br/>---<br/>Modified by KV to set attributes in Quest.]]></attr>
  </object>
  <command name="credits">
    <pattern>about;credits;info</pattern>
    <script><![CDATA[
      msg ("<hr/>"+js.implementation_notes+"<hr/>")
    ]]></script>
  </command>
  <command name="version">
    <pattern>version</pattern>
    <script>
      msg (game.gamename+": version "+game.version)
    </script>
  </command>
  <function name="SetMonth" parameters="month">
    calendar.month = month
  </function>
  <function name="HolidayMessage" parameters="holiday" type="string">
    return (StringDictionaryItem(calendar.holidays,holiday))
  </function>
  <function name="SetHoliday" parameters="holiday">
    calendar.isHoliday = true
    calendar.holiday = holiday
  </function>
  <function name="SetDay" parameters="day">
    calendar.day = day
  </function>
  <function name="SetTempF" parameters="temp">
    calendar.tempF = temp
  </function>
  <function name="SetWeatherCode" parameters="weatherCode">
    calendar.weatherCode = weatherCode
  </function>
  <function name="SetCityFromWeather" parameters="city">
    calendar.weatherCity = city
  </function>
  <function name="SetTempCelsius" parameters="tempCelsius">
    calendar.tempC = tempCelsius
  </function>
  <function name="WeatherStatus" parameters="code" type="string">
    status = StringDictionaryItem(calendar.weatherCodeDict,code)
    return (status)
  </function>
  <function name="SetCityManually" parameters="city">
    calendar.playerCity = city
  </function>
  <function name="SetYear" parameters="year">
    calendar.year = year
  </function>
  <function name="SetDate" parameters="date">
    calendar.dateAsString = date
  </function>
  <function name="SetTime" parameters="time">
    calendar.timeJS = time
  </function>
  <function name="SetHours" parameters="hrs">
    calendar.hoursJS = ToInt(hrs)
  </function>
  <function name="SetMinutes" parameters="min">
    calendar.minutesJS = ToInt(min)
  </function>
  <function name="IsHoliday" type="boolean">
    date = calendar.month + ""+calendar.day
    foreach (holiday, calendar.holidayDates) {
      if (date = holiday) {
        calendar.isHoliday = true
        calendar.holiday = StringDictionaryItem(calendar.holidayDates,holiday)
        return (true)
      }
    }
    return (false)
  </function>
  <function name="BreakDateDown" parameters="param">
    // JS.alert (param)
    params = Split(param,";")
    calendar.hoursJS = params[0]
    calendar.hoursJS = ToInt(calendar.hoursJS)
    calendar.minutesJS = params[1]
    calendar.minutesJS = ToInt(calendar.minutesJS)
    calendar.timeJS = params[2]
    calendar.dateAsString = params[3]
    calendar.year = params[4]
    calendar.month = params[5]
    calendar.day = params[6]
  </function>
  <function name="GetMonthName" parameters="month" type="string">
    return (StringDictionaryItem(calendar.monthDict,month))
  </function>
</asl>

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums