Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Basic weather and date script

1401981631

Edited 1402002874
DXWarlock
Sheet Author
API Scripter
I made a basic weather and date script since the other one seems to have went inactive. its no where NEAR as indepth as that one, but it does what I need. it will: Advance the day and announce the days weather (days/months are fixed to whatever the _max of Month and Day are). Let you randomly pick a weather at anytime without advancing the day. If rain or snow type is found, looks at the temperature and changes it to the correct one..(say its 60 and snow, it will change it to rain..and vice versa) In extreme temps of either cold or hot, warn players of over exposer warnings. (under 10F or over 90F) Commands are: !day to advance the day and send a forecast !weather to announce a random forecast change It outputs the forecast to chat like so: <a href="http://i.imgur.com/ziIcGoz.jpg" rel="nofollow">http://i.imgur.com/ziIcGoz.jpg</a> Also it assumes there is a character named 'zCalander' with attributes of Month, Day, Year Month and Day need a current and max, Year only a current. To change the chances of the types you edit the "c(whatever)" like cRian, cFog, etc. The entire bottom is the type of each it can describe, can edit them to get different forecasts for each type. For the average temp, Base: 10 for january for example is the base temperature to use for that month and will adjust it -+25 degrees for temp range. Its probably not the most user friendly script and take some editing of types and temp and such to fit your game..but since i had it, and people pop up looking for something thought id share it. edit: edited to add missing variables: var fPart = "&lt;div style='box-shadow: 3px 3px 2px "+bShadow+"; font-family: Verdana; text-shadow: 2px 2px #000; text-align: center; vertical-align: middle; padding: 2px 2px; margin-top: 0.2em; border: 1px solid #000; border-radius: 8px 8px 8px 8px; color: #FFFFFF;" var bShadow ="#707070"; //CODE----------------- on("chat:message", function (msg) { var msgTxt = msg.content; if (msg.type == "api" && msgTxt.indexOf('!day') !== -1) { var Day = fPart+" background-color:#0000ff;'&gt;A New Day is here!&lt;/div&gt;"; sendChat('', "/direct " + Day); var calanderPC = findObjs({_type: 'character',name: 'zCalendar'})[0]; //day lookup var Day = findObjs({name: "Day",_type: "attribute",_characterid: calanderPC.id}, {caseInsensitive: true})[0]; var DayNum = parseInt(Day.get("current")); var mDayNum = parseInt(Day.get("max")); //month lookup var Month = findObjs({name: "Month",_type: "attribute",_characterid: calanderPC.id}, {caseInsensitive: true})[0]; var MonthNum = parseInt(Month.get("current")); var mMonthNum = parseInt(Month.get("max")); //year lookup var Year = findObjs({name: "Year",_type: "attribute",_characterid: calanderPC.id}, {caseInsensitive: true})[0]; var YearNum = parseInt(Year.get("current")); Day.set('current', DayNum + 1); if (DayNum &gt; mDayNum) { Day.set('current', 1); Month.set('current', MonthNum + 1); } if (MonthNum &gt; mMonthNum) { Month.set('current', 1); Year.set('current', YearNum + 1); } weath(); } if (msg.type == "api" && msgTxt.indexOf('!weather') !== -1) { weath(); } function weath() { //Get Date----------------- var croll = findObjs({_type: 'character',name: 'zCalendar'})[0]; var oMonth = findObjs({name: "Month",_type: "attribute",_characterid: croll.id}, {caseInsensitive: true})[0]; var MonthNum = parseInt(oMonth.get("current")); var oDay = findObjs({name: "Day",_type: "attribute",_characterid: croll.id}, {caseInsensitive: true})[0]; var oDay = parseInt(oDay.get("current")); var oYear = findObjs({name: "Year",_type: "attribute",_characterid: croll.id}, {caseInsensitive: true})[0]; var oYearNum = parseInt(oYear.get("current")); //Lookup name----------------- MonthId.forEach(function (opts) { if (MonthNum == opts.Month) { var cRare = 5; var cSnow = 10; var cRain = 15; var cFog = 25; var cMagnetic = 30; var MonthName = opts.Name; var date = MonthName + ', ' + oDay + " " + oYearNum + ' PA'; //---find temp var rN = Math.floor(Math.random() * 50) - 25; var tChange = rN; var TempBase = (opts.Base + rN); var TempBaseReal = (opts.Base + rN); if (TempBase &lt;= 10) { var TempBase = TempBase + "F (Exposer Warning!)"; } else if (TempBase &gt;= 90) { var TempBase = TempBase + "F (Heat Warning!)"; } else { var TempBase = TempBase + "F "; } //---------- var ranType = randomInteger(100); if (ranType &lt; cRare) { oType = "Rare"; } else if (ranType &lt; cSnow) { oType = "Snow"; } else if (ranType &lt; cRain) { oType = "Rain"; } else if (ranType &lt; cFog) { oType = "Fog"; } else if (ranType &lt; cMagnetic) { oType = "Magnetic"; } else { oType = "Calm"; } //---------- if (TempBaseReal &lt;= 35 & oType == "Rain") oType = "Snow"; if (TempBaseReal &gt; 35 & oType == "Snow") oType = "Rain"; //---------- array_name = eval(oType); var oDesc = array_name[Math.floor(Math.random() * array_name.length)]; if (oType == 'Fog') tColor = 'http:\\//img.photobucket.com/albums/v58/PixelMagic/Blog%20Images/fog_element.jpg'; if (oType == 'Rain') tColor = 'http:\\//2.bp.blogspot.com/-FIM7eNMpYr8/Uj8oOwqQt8I/AAAAAAAAAUY/Un2z7gY4LMw/s320/pouring+rain.jpg'; if (oType == 'Snow') tColor = 'http:\\//<a href="http://www.ruralramblings.com/wp-content/uploads/2011/01/southern-snowflakes_8766.jpg" rel="nofollow">www.ruralramblings.com/wp-content/uploads/2011/01/southern-snowflakes_8766.jpg</a>'; if (oType == 'Magnetic') tColor = 'http:\\//media2.newsnet5.com//photo/2012/01/24/aurora_20120124151932_320_240_20120124153254_320_240.JPG'; if (oType == 'Calm') tColor = 'http:\\//<a href="http://www.mrwallpaper.com/wallpapers/blue-sunny-sky-851x315.jpg" rel="nofollow">www.mrwallpaper.com/wallpapers/blue-sunny-sky-851x315.jpg</a>'; if (oType == 'Rare') tColor = 'https:\\//c2.staticflickr.com/2/1406/5128618911_e17c2474b5.jpg'; var output1 = "&lt;b&gt;" + date; var output2 = '&lt;b&gt;Temp: ' + TempBase + '&lt;br&gt;&lt;u&gt;&lt;i&gt;DayType: ' + oType; //---------- var top = "&lt;div style='background-position:center; box-shadow: 3px 3px 2px "+bShadow+"; text-shadow: 2px 2px #000; font-family: Arial; font-size:18px; text-align: center; vertical-align: middle; padding: 0px 0px; margin-top: 0.2em; border: 1px solid #000; border-radius: 10px 10px 0px 0px; color: #FFFFFF; background-image: url("+tColor+");'&gt;" + output1 + "&lt;/div&gt;"; var MainSay = "&lt;div style='box-shadow: 3px 3px 2px "+bShadow+"; font-family:Arial; text-align: center; vertical-align: middle; padding: 1px; border-left: 1px solid #000; border-right: 1px solid #000; border-radius: 0px; background-color: #BFB8A8; color: #000;'&gt;" + output2 + "&lt;/div&gt;"; var MainEven = "&lt;div style='box-shadow: 3px 3px 2px "+bShadow+"; font-family: Arial; text-align: center; vertical-align: middle; padding: 1px; border-left: 1px solid #000; border-right: 1px solid #000; border-radius: 0px; background-color: #CEC7B6; color: #000;'&gt;" + oDesc + "&lt;/div&gt;"; var End = "&lt;div style='background-position:center; box-shadow: 3px 3px 2px "+bShadow+"; padding: 5px; border-left: 1px solid #000; border-right: 1px solid #000; border-radius: 0px 0px 10px 10px; border: 1px solid #000; background-image: url("+tColor+"); color: #000;'&gt;&lt;/div&gt;"; sendChat('', "/direct " + top + MainSay + MainEven + End); } }); }; }); /*------------------ WEATHER STUFF ------------------*/ //---MONTH var MonthId = [ {Month: 1,Name: 'January',Base: 10}, {Month: 2,Name: 'February',Base: 20}, {Month: 3,Name: 'March',Base: 40}, {Month: 4,Name: 'April',Base: 60}, {Month: 5,Name: 'May',Base: 70}, {Month: 6,Name: 'June',Base: 80}, {Month: 7,Name: 'July',Base: 90}, {Month: 8,Name: 'August',Base: 80}, {Month: 9,Name: 'September',Base: 60}, {Month: 10,Name: 'October',Base: 30}, {Month: 11,Name: 'November',Base: 20}, {Month: 12,Name: 'December',Base: 10} ]; //---FOG TYPES var Fog = [ "Light Fog: Visibility reduced to 1/2 mile", "Heavy Fog: Visibility reduced to 1/4 mile", "Dense Fog: Visibility reduced to 100 feet and anything over 10mph is wreckless travel, +15 to prowl" ]; //---RAIN TYPES var Rain = [ "Light Rain", "Heavy Rain: Travel is treacherous in the mud and slick conditions Hard to see road or paths. Land navigation at -15%", "Downpour: Sheets of rain cover any and everything, seeing out of windows or visors a problem. Land navigation at -20%", "ThunderStorm: Best to lay low, strong rain, lightning, and high gusts of winds common. Land navigation at -30%" ]; //---SNOW TYPES var Snow = [ "Light Snow: Tracking is at -25%", "Heavy Snow: Progress cut in 1/2 and following tracks impossible. Land navigation at -30%", "Blizzard: The combination of high winds, heavy snow (typically 3d4 feet), and bitter cold make blizzards deadly for all who are unprepared for them. Progress is slow at best visibility is a 100 feet. Land navigation at -50%", "Whiteout: Progress is slow and cautious visibility is a few feet. making Spot, Search, and Listen checks and all ranged weapon attacks impossible. Land navigation at -90%", "Small hail: pea sized balls of hail, Combat is -4 to hit due to you and your gun being pelted with the hail", "Large hail: Baseball sized hail falls, anyone not in armor or shelter takes 1d8 damage per 5 minutes exposed. Hearing or hitting anything outside arm reach is impossible due to the noise" ]; //---MAG TYPES var Magnetic = [ "Light Magnetic Storm: Radio range is 1/2, and electronic and mechanical compasses off by 1d20 degrees", "Heavy Magnetic Storm: Radio is useless, and electronic and mechanical compasses spin wildly" ]; //---CALM TYPES var Calm = [ "Very Light Winds, clear sky, its a beautiful day! Seems a great day for travel. Progress is at 110% and +10 to land navigation and tracking", "A nice clear day +10 to land navigation", "Very overcast, sun and sky hiding behind clouds. -10 to land navigation", "Overcast sky, light breezes, and overall pleasent conditions for the season", "A typical day like any other. Partially cloudy, calm winds.", "Clear skys, but higher than usual winds. prowling in bushes and wooded areas is easier +10 to prowl", "Clear skys, and dead calm winds. Prowling in quiet areas and wilderness is noticable, -10 to prowl" ]; //---RARE TYPES var Rare = [ "Incorporeal Wind: Incorporeal wind passes through physical objects and barriers, such as clothing, armor, walls, and solid earth and stone. It negates any benefit of winter clothing against cold and exposure effects, but also negates any penalty for heavy clothing or armor against heat. Incorporeal wind is blocked only by mage armor, wall of force, and similar force effects.", "Ghoststorm: A chill windstorm brings a cacophany of noises, including the lost voices of the dead. -8 penalty on Listen checks due to the howling of the wind. Ranged weapon attacks are impossible", "Celestial Clarity: The sky is a perfect azure blue, colors seem more vibrant, and details appear sharper. Celestial clarity grants a +4 bonus to Spot, Search, Listen, and Sense Motive checks.", "Rogue Zephyr: Rogue zephyrs are gentle but magical breezes which undo simple knots, locks, bolts, manacles, shackles, and similar impediments", "Undead fog: A fog comes, bringing with it the rising of any dead engulfed in the ground in its grasp. Some seek comfort, some want justice, others want revenge.", "Gale Force Winds: Winds over 70MPH tear around the landscape. Standing outside is near impossible. Small debris and rocks cause 1d10 damage for every minute outside." ];
1401999173

Edited 1402001135
I will definitely be checking this out when I get home today. Will update this post. Will you not be including time? Was a really good aspect of the other sheet. Can you customize the calendar as in the other one? What is the calendar system? I created my world to utilize the one he was using. Are you planning on updating it to have different climates? If your in the arctic, no matter what time of year, it'll be cold. Can I edit the number of days if it goes to a month which has an extra week? Basically, are you going to be updating this with any more of the calendar/time features. I don't know anything about javascript, but can't you just do something like this? if (MinuteNum&gt; mMinuteNum) { Minute.set('current', 0); Hour.set('current', HourNum + 1); } if (HourNum&gt; mHourNum) { Hour.set('current', 0); Day.set('current', DayNum + 1); } and then we can use macros to increase the minutes/hours (days too) just like in the other script.
1402001713

Edited 1402002794
DXWarlock
Sheet Author
API Scripter
The time could be added. I didn't have it in mine since we play more by rough time of day by hours (its about 5pm, 7pm etc). I have a rollable table with clock face images I advanced thats on the current page so people can see the time of day. For the other things, dont think Im getting that in depth with it. Reason I didn't use the other one when it was working right. was too much info for my simple calendar needs. Since we play in one regional area roughly the same climate. and my players aren't picky about how many days each month has, and tides/moon phase wouldn't matter to us and so on. Plus my javascript level is hobby amateur at best. me trying to add more would just cause more bugs people could report..lol Was sharing more incase someone wanted to use it, or expand on it themselves as a basic jumping point :) If anyone wants to grab it and clean up (as im sure there is LOT easier ways to do what I'm doing in it) or expand on it and even reshare it again..they are more than welcome to.
Okay. It's kicking me an error that says that bShadow and fPart are not defined when I try to use !weather or !day
1402002280

Edited 1402002503
DXWarlock
Sheet Author
API Scripter
Ah crap..forgot I had those variables in my commonly used 'callbacks' script. I edited the post and added them to the code at the top.
It works. Cool, thanks a ton.
Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: ReferenceError: fPart is not defined at Sandbox.&lt;anonymous&gt; (evalmachine.&lt;anonymous&gt;:121:19) at eval ( This happened to me. Did I miss something?
1403015898
The Aaron
Roll20 Production Team
API Scripter
Did you pull a new copy after he added the fPart and bShadow variables to the top? var fPart = "&lt;div style='box-shadow: 3px 3px 2px "+bShadow+"; font-family: Verdana; text-shadow: 2px 2px #000; text-align: center; vertical-align: middle; padding: 2px 2px; margin-top: 0.2em; border: 1px solid #000; border-radius: 8px 8px 8px 8px; color: #FFFFFF;" var bShadow ="#707070";