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 .
×
Advertisement Create a free account

[AdvancedCalendar] Changes in Plugin not showing in Game and Weather formating malfunction

1626439018
I have been using the AdvancedCalendar with a custom plugin changed from The Aron and Caio Viel. I have some questions for the changes I have done: First: I have been doing some changes in the plugin script (number of months, seasons and days in months). The script is not crashing but the info is not being updated in the game. I even tried to use another one of Caio Viel plugins, but it keeps returning the data of the old calendar. When I created the same scripts in a new game it brings the right info. Do I need to clear any data in my game to reset the info? I mean, it must save the logs and current date in some place, but I didn`t find any handout or anything in the code. My second doubt is about the weather part. It is not bringing the formatting color and info as it brought before. Its output is: Qiirag - 25 Luvitas, 1483 CA heatWave - without formatting. The code I have been using is this: Advanced Calendar: var Climate = { COLD : 0, DESERT : 1, TEMPERATE : 2, }; var Season = { SPRING : 0, SUMMER : 1, FALL : 2, WINTER : 3, SSFW: 4 }; var WeatherRandomGenerator = WeatherRandomGenerator || { version : 1.0, CheckInstall: function(calendar) { if(! state.hasOwnProperty('WeatherRandomGenerator') || state.WeatherRandomGenerator.version != WeatherRandomGenerator.version) { // Default Settings stored in the state. state.WeatherRandomGenerator = { version: AdvancedCalendar.version, climate: Climate.TEMPERATE, options: { useMetricalSystem : true } } } }, _randomNumber : function(min, max) { return Math.floor((Math.random() * (max-min)) + min); }, _GetWeatherAsString : function(w) { return w.name + ' - ' + w.description; }, _normalWeather : function(climate, season) { if (climate == Climate.COLD) { var w = { name : "cold", temperatureHigh : WeatherRandomGenerator._randomNumber(0, 40), windSpeed : WeatherRandomGenerator._randomNumber(0, 10), description: "", }; w["temperatureLow"] = w.temperatureHigh - WeatherRandomGenerator._randomNumber(10, 20); return w; } else if (climate == Climate.TEMPERATE) { if (season == Season.SPRING || season == Season.FALL) { var w = { temperatureHigh : WeatherRandomGenerator._randomNumber(40, 70), windSpeed : WeatherRandomGenerator._randomNumber(0, 10), description: "", }; w["temperatureLow"] = w.temperatureHigh - WeatherRandomGenerator._randomNumber(10, 20); if (w.temperatureHigh &lt; 50) { w["name"] = "cold"; } else { w["name"] = "warm"; } return w; } else if (season == Season.SUMMER) { var w = { name : "warm", temperatureHigh : WeatherRandomGenerator._randomNumber(60, 85), windSpeed : WeatherRandomGenerator._randomNumber(0, 10), description: "", }; w["temperatureLow"] = w.temperatureHigh - WeatherRandomGenerator._randomNumber(10, 20); return w; } else { var w = { name : "cold", temperatureHigh : WeatherRandomGenerator._randomNumber(0, 40), windSpeed : WeatherRandomGenerator._randomNumber(0, 10), description: "", }; w["temperatureLow"] = w.temperatureHigh - WeatherRandomGenerator._randomNumber(10, 20); return w; } } else { var w = { name : "hot", temperatureHigh : WeatherRandomGenerator._randomNumber(85, 110), windSpeed : WeatherRandomGenerator._randomNumber(0, 10), description: "", }; w["temperatureLow"] = w.temperatureHigh - WeatherRandomGenerator._randomNumber(10, 20); return w; } }, _abnormalWeather : function(climate, season) { var w = WeatherRandomGenerator._normalWeather(climate, season); if (climate == Climate.DESERT) { w.name = "windy", w.windSpeed = WeatherRandomGenerator._randomNumber(10, 30); } else { var d100 = WeatherRandomGenerator._randomNumber(1, 100); if ( (climate == Climate.COLD &amp;&amp; d100 &lt;= 30) || (climate == Climate.TEMPERATE &amp;&amp; d100 &lt;= 50) ) { w.name = "heatWave"; w.temperatureHigh += 10; w.temperatureLow += 10; } else { w.name = "coldSnap"; w.temperatureHigh -= 10; w.temperatureLow -= 10; } } return w; }, _inclementWeather : function(climate, season) { var w = WeatherRandomGenerator._normalWeather(climate, season); if (climate == Climate.DESERT) { w.name = "windy"; w.windSpeed = WeatherRandomGenerator._randomNumber(10, 30); } else if (climate == Climate.COLD) { w.name = 'snow'; w.description = "" + WeatherRandomGenerator._randomNumber(2, 8) + " hours of snow."; } else { var d100 = WeatherRandomGenerator._randomNumber(1, 100); if (d100 &lt;= 30) { w.name = "fog"; w.description = "" + WeatherRandomGenerator._randomNumber(2, 8) + " hours of fog."; } else if (d100 &lt;=90) { if (w.temperatureHigh &lt;= 30) { w.name = "snow"; w.description = "" + WeatherRandomGenerator._randomNumber(2, 8) + " hours of snow."; } else { w.name = "rain"; w.description = "" + WeatherRandomGenerator._randomNumber(2, 8) + " hours of rain."; } } else { if (w.temperatureHigh &lt;= 30) { w.name = "sleet"; w.description = "" + WeatherRandomGenerator._randomNumber(2, 8) + " hours of sleet."; } else { w.name = "hail"; w.description = "" + WeatherRandomGenerator._randomNumber(1, 20) + " of minutes of hail followed by " + WeatherRandomGenerator._randomNumber(1,4) + " hours of rain."; } } } return w; }, _storm : function(climate, season) { var w = WeatherRandomGenerator._normalWeather(climate, season); w.windSpeed = WeatherRandomGenerator._randomNumber(30, 50); if (climate == Climate.DESERT) { w.name = "duststorm"; w.description = "" + WeatherRandomGenerator._randomNumber(1, 7) + " hours of duststom."; } else if (climate == Climate.COLD) { w.name = "snowstorm"; w.description = "" + WeatherRandomGenerator._randomNumber(1, 7) + " hours of snowstorm."; } else { if (w.temperatureHigh &lt;= 30) { w.name = "snowstorm"; w.description = "" + WeatherRandomGenerator._randomNumber(1, 7) + " hours of snowstorm."; } else { var d10 = WeatherRandomGenerator._randomNumber(1, 20); if (d10 == 1) { w.name = "tornado"; w.description = "" + WeatherRandomGenerator._randomNumber(1, 7) + " hours of thunderstorm with " + "tornado (wind speed " + WeatherRandomGenerator.GetSpeed(WeatherRandomGenerator._randomNumber(175, 300)) + ") for " + WeatherRandomGenerator._randomNumber(10, 60) + " minutes."; } else { w.name = "thunderstorm"; w.description = "" + WeatherRandomGenerator._randomNumber(1, 7) + " hours of thunderstorm."; } } } return w; }, _powerfulStorm : function(climate, season) { var w = WeatherRandomGenerator._normalWeather(climate, season); if (climate == Climate.DESERT) { w.name = "downspor"; w.windSpeed = WeatherRandomGenerator._randomNumber(30, 50); w.description = "" + WeatherRandomGenerator._randomNumber(2, 8) + " hours of downspor."; } else if (climate == Climate.COLD) { w.name = "blizzard"; w.windSpeed = WeatherRandomGenerator._randomNumber(51, 74); w.description = "" + WeatherRandomGenerator._randomNumber(1, 3) + " days of blizzard."; } else { if (w.temperatureHigh &lt;= 30) { w.name = "blizzard"; w.windSpeed = WeatherRandomGenerator._randomNumber(51, 74); w.description = "" + WeatherRandomGenerator._randomNumber(1, 3) + " days of blizzard."; } else { var percent = WeatherRandomGenerator._randomNumber(1, 100); if (w.windSpeed &lt; 75) { w.name = "windstorm"; w.windSpeed = WeatherRandomGenerator._randomNumber(51, 74); w.description = "" + WeatherRandomGenerator._randomNumber(1, 6) + " hours of windstorm."; } else { w.name = "hurricane"; w.windSpeed = WeatherRandomGenerator._randomNumber(75, 174); w.description = "" + WeatherRandomGenerator._randomNumber(1, 7) + " days of hurricane."; } } } return w; }, GetSpeed : function (speed) { if (state.WeatherRandomGenerator.options.useMetricalSystem) { return Math.ceil(speed*1.6) + " km/h"; } else { return speed + " mph"; } }, GetTemperature : function (temperature) { if (state.WeatherRandomGenerator.options.useMetricalSystem) { return Math.ceil((temperature-32)/1.8) + " °C"; } else { return temperature + " °F"; } }, GenerateWeather : function(season) { var d100 = WeatherRandomGenerator._randomNumber(1, 100); var climate = state.WeatherRandomGenerator.climate; if (d100 &lt;= 70) { //Normal Weather return WeatherRandomGenerator._normalWeather(climate, season); } else if (d100 &lt;= 80) { //Abnormal Weather return WeatherRandomGenerator._abnormalWeather(climate, season); } else if (d100 &lt;= 90) { //Inclement weather return WeatherRandomGenerator._inclementWeather(climate, season); } else if (d100 &lt;= 99) { //Storm return WeatherRandomGenerator._storm(climate, season); } else { //Powerful Storm return WeatherRandomGenerator._powerfulStorm(climate, season); } }, RegisterEventHandlers : function() { } }; var AdvancedCalendar = AdvancedCalendar || { version: 1.0, lunarPhaseSize: 15, lunarPhasesImage: '<a href="https://s3.amazonaws.com/files.d20.io/images/4277527/CJJWBbiHx3jHglPdccPx3A/max.png?1401939451" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/4277527/CJJWBbiHx3jHglPdccPx3A/max.png?1401939451</a>', clearImage: '<a href="https://s3.amazonaws.com/files.d20.io/images/4277467/iQYjFOsYC5JsuOPUCI9RGA/max.png?1401938659" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/4277467/iQYjFOsYC5JsuOPUCI9RGA/max.png?1401938659</a>', seasonImage: '<a href="https://i.imgur.com/3fbHUaO.png" rel="nofollow">https://i.imgur.com/3fbHUaO.png</a>', seasonImageSize : 30, weatherImage : '<a href="https://s3.amazonaws.com/files.d20.io/images/15894686/Zaby88WaMRSRO104_1eAug/original.png?14544320015" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/15894686/Zaby88WaMRSRO104_1eAug/original.png?14544320015</a>', weatherImageSize : 30, weatherImageBorderHorizontal: 14.5, weatherImageVerticalBorder: 11, weathersIcons : { hot: {name: "hot", x: 0, y: 1}, warm: {name: "warm", x: 1, y: 1}, cold: {name: "cold", x: 2, y: 1}, heatWave: {name: "heat wave", x: 3, y: 7}, coldSnap: {name: "cold snap", x: 4, y: 7}, calm: {name: "calm", x: 0, y: 5}, windy: {name: "windy", x: 1, y: 5}, windstorm: {name: "windstorm", x: 2, y: 5}, hurricane: {name: "hurricane", x: 3, y: 5}, tornado: {name: "tornado", x: 3, y: 5}, fog: {name: "fog", x: 7, y: 4}, rain: {name: "rain", x: 6, y: 1}, hail: {name: "hail", x: 9, y: 1}, downspor: {name: "downspor", x: 0, y: 2}, thunderstorm: {name: "thunderstorm", x: 3, y: 2}, snow: {name: "snow", x: 5, y: 4}, sleet: {name: "sleet", x: 3, y: 3}, snowstorm: {name: "snowstorm", x: 8, y: 4}, blizzard: {name: "blizzard", x: 9, y: 4}, duststorm: {name: "duststorm", x: 1, y: 4} }, _Ordinal: function(num) { var ones=(num%10); var tens=((num%100)-ones); switch(ones) { case 1: return ((10 == tens) ? 'th' : 'st'); case 2: return ((10 == tens) ? 'th' : 'nd'); case 3: return ((10 == tens) ? 'th' : 'rd'); default: return 'th'; } }, _GetOptionsFromTokens: function (tokens) { var options={}; var switches=_.filter(tokens, function(tok){ return null != tok.match(/^--/); }); _.each(switches,function(s){ switch(s) { case '--lunar': options.showLunarPhases=true; break; case '--nolunar': options.showLunarPhases=false; break; } }); return options; }, CheckInstall: function(calendar) { if(! state.hasOwnProperty('AdvancedCalendar') || state.AdvancedCalendar.version != AdvancedCalendar.version) { log("Reseting calendar data..."); // Default Settings stored in the state. state.AdvancedCalendar = { version: AdvancedCalendar.version, now: calendar.startingDate, setting: calendar.setting, holidays : calendar.holidays, schedule: {}, } } }, SetWeather: function(date, weather) { var dateId = (AdvancedCalendar._GetTotalDaysForDate(date)).toString(); if (! _.has(state.AdvancedCalendar.schedule, dateId)) { state.AdvancedCalendar.schedule[dateId] = {}; } state.AdvancedCalendar.schedule[dateId]["weather"] = weather; }, GetWeather: function(date) { var dateId = (AdvancedCalendar._GetTotalDaysForDate(date)).toString(); var sched = state.AdvancedCalendar.schedule; if (_.has(sched, dateId) &amp;&amp; _.has(sched[dateId], "weather")) { return sched[dateId]["weather"]; } else { var s = state.AdvancedCalendar.setting; var season = s.monthsOfTheYear[date.month -1].season; log(season); var w = WeatherRandomGenerator.GenerateWeather(season); sched[dateId] = {}; sched[dateId]["weather"] = w; return w; } }, ChangeWeather: function(date) { var dateId = (AdvancedCalendar._GetTotalDaysForDate(date)).toString(); var sched = state.AdvancedCalendar.schedule; if (_.has(sched, dateId) &amp;&amp; _.has(sched[dateId], "weather")) { sched[dateId]["weather"] = WeatherRandomGenerator.GenerateWeather(season); } else { var s = state.AdvancedCalendar.setting; var season = s.monthsOfTheYear[date.month -1].season; log(season); var w = WeatherRandomGenerator.GenerateWeather(season); sched[dateId] = {}; sched[dateId]["weather"] = w; } }, AddLog: function(date, character, log, isNote) { var dateId = (AdvancedCalendar._GetTotalDaysForDate(date)).toString(); if (! _.has(state.AdvancedCalendar.schedule, dateId)) { state.AdvancedCalendar.schedule[dateId] = {}; state.AdvancedCalendar.schedule[dateId]["logs"] = []; } else if (! _.has(state.AdvancedCalendar.schedule[dateId], "logs")) { state.AdvancedCalendar.schedule[dateId]["logs"] = []; } state.AdvancedCalendar.schedule[dateId]["logs"].push( {character: character, log: log, isNote: isNote }); }, GetLogs: function(date) { var dateId = (AdvancedCalendar._GetTotalDaysForDate(date)).toString(); var sched = state.AdvancedCalendar.schedule; if (_.has(sched, dateId) &amp;&amp; _.has(sched[dateId], "logs")) { return sched[dateId]["logs"]; } else { return []; } }, AdvanceDays: function(days){ var n = state.AdvancedCalendar.now; var s = state.AdvancedCalendar.setting; log(n); var y = Math.floor(days/s.daysOfYear); days-=(y*s.daysOfYear); log(n.day + days); log(s.monthsOfTheYear[n.month -1].days); while (n.day + days &gt; s.monthsOfTheYear[n.month -1].days) { days = days - s.monthsOfTheYear[n.month -1].days + n.day; n.day = 0; n.month++; if (n.month &gt; 13) { n.month = 1; n.year++; } } log("days: " + days); log("years: " + y); n.day += days; n.year = n.year + y; state.AdvancedCalendar.now=n; }, RemoveDays: function(days){ var n = state.AdvancedCalendar.now; var s = state.AdvancedCalendar.setting; var y = Math.floor(days/s.daysOfYear); days-=(y*s.daysOfYear); while (days &gt;= n.day) { days = days - n.day; n.month--; if (n.month &lt; 1) { n.month = 13; n.year--; } n.day = s.monthsOfTheYear[n.month -1].days; } n.day-=days; n.year-=y; state.AdvancedCalendar.now=n; }, _GetTotalDaysForDate: function(d) { var s = state.AdvancedCalendar.setting; var totalDays = d.year*s.daysOfYear; for (var i=0; i &lt; d.month-1; i++) { totalDays += s.monthsOfTheYear[i].days; } totalDays += d.day; return totalDays; }, _GetWeekDayForDate: function(d) { var s = state.AdvancedCalendar.setting; var totalDays = AdvancedCalendar._GetTotalDaysForDate(d); var weekday = totalDays % s.daysOfTheWeek.length; return ( weekday ? weekday : 7); }, _GetPhaseForDate: function(d,options){ var opt=_.defaults((options||{}),{ showLunarPhases: true }); return ((opt.showLunarPhases)?( '&lt;img src="' +AdvancedCalendar.clearImage +'" style="margin-left: 4px; vertical-align: top;width: '+AdvancedCalendar.lunarPhaseSize+'px; height: '+AdvancedCalendar.lunarPhaseSize+'px; background:url(' +AdvancedCalendar.lunarPhasesImage +') -'+(AdvancedCalendar._GetTotalDaysForDate(d) % 7)*AdvancedCalendar.lunarPhaseSize +'px -'+Math.floor( AdvancedCalendar._GetTotalDaysForDate(d) / 7)*AdvancedCalendar.lunarPhaseSize+'px;"&gt;' ):('')); }, _GetWeatherForDate: function(d, options) { var opt=_.defaults((options||{}),{ showWeather: true }); var w = AdvancedCalendar.GetWeather(d); return ((opt.showWeather)?( '&lt;div style="color: white; font-family: Arial; text-align: left; vertical-align: middle;' +'line-height: 30px"&gt;' + AdvancedCalendar._GetWeatherImage(w) + " " + AdvancedCalendar.weathersIcons[w.name].name +'&lt;/div&gt;' +'&lt;div style="color: white; font-family: Arial; text-align: left;" &gt;' + "max: " + WeatherRandomGenerator.GetTemperature(w.temperatureHigh) + " min: " + WeatherRandomGenerator.GetTemperature(w.temperatureLow) + '&lt;br&gt;' + "wind speed: " + WeatherRandomGenerator.GetSpeed(w.windSpeed) + "&lt;br&gt;" + w.description +'&lt;/div&gt;' ):('')); }, _GetWeatherImage: function(w) { var i = AdvancedCalendar.weathersIcons[w.name]; return '&lt;img src="' +AdvancedCalendar.clearImage +'" style="margin-left: 4px; vertical-align: top;width: '+AdvancedCalendar.weatherImageSize+'px; height: '+AdvancedCalendar.weatherImageSize+'px; background:url(' +AdvancedCalendar.weatherImage +') -'+(AdvancedCalendar.weatherImageSize + AdvancedCalendar.weatherImageBorderHorizontal)*i.x +'px -'+ (AdvancedCalendar.weatherImageSize + AdvancedCalendar.weatherImageVerticalBorder)*i.y+'px;"&gt;'; }, _GetSeasonForDate: function(d,options){ s = state.AdvancedCalendar.setting; var opt=_.defaults((options||{}),{ showSeason: true }); return ((opt.showSeason)?( '&lt;div style="color: white; font-family: Arial; text-align: center; vertical-align: middle;' +'line-height: 30px"&gt;' +AdvancedCalendar._GetSeasonImageForDate(d) + " " + s.seasons[s.monthsOfTheYear[d.month-1].season] +'&lt;/div&gt;' ):('')); }, _GetSeasonImageForDate: function(d,options){ s = state.AdvancedCalendar.setting; var opt=_.defaults((options||{}),{ showSeason: true }); return ((opt.showSeason)?( '&lt;img src="' +AdvancedCalendar.clearImage +'" style="margin-left: 4px; vertical-align: top;width: '+AdvancedCalendar.seasonImageSize+'px; height: '+AdvancedCalendar.seasonImageSize+'px; background:url(' +AdvancedCalendar.seasonImage +') -' + s.monthsOfTheYear[d.month-1]["season"] * AdvancedCalendar.seasonImageSize +'px;"&gt;' ):('')); }, _GetHolidays: function(d, options) { var opt=_.defaults( (options||{}), { showHolidays: true }); var s = state.AdvancedCalendar.holidays; var dayId = d.day + "/" + d.month; if (opt.showHolidays &amp;&amp; _.has(s, dayId)) { var temp = "&lt;div&gt;"; _.each(s[dayId], function(h) { var t = '&lt;span style="font-weight: bold;"&gt;' + h.name; if (h.area != "") { t += " (" + h.area + "): &lt;/span&gt;" } else { t += ": :&lt;/span&gt;" } if (h.description != "") { t += h.description; } temp += "&lt;br&gt;" + t; }); temp += "&lt;/div&gt;"; return temp; } else { return ''; } }, _GetLogs: function(d, options) { var opt=_.defaults( (options||{}), { showLogs: true }); var logs = AdvancedCalendar.GetLogs(d); if (opt.showLogs) { var temp = "&lt;div&gt;"; _.each(logs, function(h) { if (!h.isNote) { var t = '&lt;span style="font-weight: bold;"&gt;' + h.character + ": "; if (h.description != "") { t += h.log; } temp += "&lt;br&gt;" + t; } }); temp += "&lt;/div&gt;"; return temp; } else { return ''; } }, _GetDayForDate: function(d,options){ var opt=_.defaults((options||{}),{ }); var n = state.AdvancedCalendar.now; var img = AdvancedCalendar._GetPhaseForDate(d,opt) if(d.year == n.year &amp;&amp; d.month == n.month &amp;&amp; d.day == n.day) { return '&lt;div style="white-space: nowrap;"&gt;' +'&lt;span style="font-weight: bold; color: #990000; font-size: 13px; background: white; border-radius: 2px; padding: 2px; box-shadow: 0 0 1px 1px red;"&gt;'+d.day +'&lt;/span&gt;' +img +'&lt;/div&gt;'; } else if( (d.year &lt; n.year) || ( (d.year &lt;= n.year) &amp;&amp; (d.month&lt;n.month)) || ( (d.year &lt;= n.year) &amp;&amp; (d.month&lt;=n.month) &amp;&amp; (d.day&lt;n.day)) ) { return '&lt;div style="white-space: nowrap;"&gt;' +'&lt;strike style="color:red; font-weight: bold;"&gt;' +'&lt;span style="font-weight:bold; color:#999999; font-size: 13px;"&gt;' +d.day +'&lt;/span&gt;' +img +'&lt;/strike&gt;' +'&lt;/div&gt;'; } else { return '&lt;div style="white-space: nowrap;"&gt;' +'&lt;span style="font-weight: bold; color: #000099; font-size: 13px;"&gt;' +d.day +'&lt;/span&gt;' +img +'&lt;/div&gt;'; } }, _GetMonthForDate: function(d,options){ var opt=_.defaults((options||{}),{ showYear: true, showMonthNumber: false }); log(d); var s=state.AdvancedCalendar.setting; var daysHeader=''; _.each(s.daysOfTheWeek,function(d){ daysHeader+='&lt;th&gt;&lt;div style="width: 25px;margin: 0px auto;"&gt;'+d.substring(0,2)+'&lt;/div&gt;&lt;/th&gt;'; }); var mday=_.clone(d); var weeks=''; mday.day=1; var rows = 0; //First week can be trick var firstWeekDay = AdvancedCalendar._GetWeekDayForDate(mday); //placing empty spaces for month that doesn't start at first week day. weeks+='&lt;tr&gt;' for (i=1; i &lt; firstWeekDay; i++) { weeks+='&lt;td style="vertical-align: middle; text-align:right;"&gt;'; weeks+= '&lt;div style="white-space: nowrap;"&gt;' +'&lt;strike style="color:red; font-weight: bold;"&gt;' +'&lt;span style="font-weight:bold; color:#999999;"&gt;' + ' ' +'&lt;/span&gt;' +'&lt;/strike&gt;' +'&lt;/div&gt;'; weeks+='&lt;/td&gt;'; } //Filling the rest of the week for (i = firstWeekDay; i &lt;= s.daysOfTheWeek.length; i++) { weeks+='&lt;td style="vertical-align: middle; text-align:center; padding:0px 5px;"&gt;'; weeks+=AdvancedCalendar._GetDayForDate(mday,opt); weeks+='&lt;/td&gt;'; mday.day++; } weeks+='&lt;/tr&gt;'; var restingWeeks = Math.ceil( (s.monthsOfTheYear[mday.month -1].days -1) / s.daysOfTheWeek.length); var j = 0; for (i= 0; i &lt; restingWeeks; i++) { weeks+='&lt;tr&gt;'; for (j=0; j &lt; s.daysOfTheWeek.length &amp;&amp; mday.day &lt;= s.monthsOfTheYear[mday.month -1].days; j++) { weeks+='&lt;td style="vertical-align: middle; text-align:center; padding:0px 5px;"&gt;'; weeks+=AdvancedCalendar._GetDayForDate(mday,opt); weeks+='&lt;/td&gt;'; mday.day++; } //filling the last week if (j &lt; s.daysOfTheWeek.length) { for (var k = j; k &lt; s.daysOfTheWeek.length; k++) { weeks+='&lt;td style="vertical-align: middle; text-align:center; padding:0px 5px;"&gt;'; weeks+= '&lt;div style="white-space: nowrap;"&gt;' +'&lt;strike style="color:red; font-weight: bold;"&gt;' +'&lt;span style="font-weight:bold; color:#999999;"&gt;' + ' ' +'&lt;/span&gt;' +'&lt;/strike&gt;' +'&lt;/div&gt;'; weeks+='&lt;/td&gt;'; } } weeks+='&lt;/tr&gt;'; } return '&lt;table style="background-color:#ffffff; min-height:210px; border-radius:5px; box-shadow: 0 0 5px 1px rgba(0,0,0,0.5);"&gt;' +'&lt;tr&gt;&lt;th colspan="'+s.daysOfTheWeek.length+'"&gt;' +'&lt;div style="float:left; padding: 0px 3px;"&gt;'+AdvancedCalendar._GetSeasonImageForDate(mday)+'&lt;/div&gt;' +((opt.showMonthNumber)?('&lt;div style="float:right; padding: 0px 3px;"&gt;'+d.month+'&lt;/div&gt;'):('')) +'&lt;div style="margin-left: auto; margin-right: auto;"&gt;' + s.monthsOfTheYear[d.month-1]["name"] +((opt.showYear)?(' '+d.year):('')) +'&lt;/div&gt;' +'&lt;/th&gt;&lt;/tr&gt;' +'&lt;tr style="border-bottom: 1px solid #aaaaaa;"&gt;'+daysHeader+'&lt;/tr&gt;' +weeks +'&lt;/table&gt;'; }, _GetYearForDate: function(d,options){ var opt=_.defaults((options||{}),{ showLunarPhases: false, showYear: false, showMonthNumber: true }); var s=state.AdvancedCalendar.setting; var yday=_.clone(d); yday.day=1; yday.month=1; var months=''; _.each(s.monthsOfTheYear, function(r){ months+='&lt;div style="float:left;padding: 2px 2px;"&gt;'; months+=AdvancedCalendar._GetMonthForDate(yday,opt); months+='&lt;/div&gt;'; yday.month++; }); return '&lt;div style="background-color: darkseagreen; padding: 15px;"&gt;' +'&lt;div style="margin: 3px 3px; font-weight: bold; font-size: 27px; color: white; text-shadow: 0px 0px 6px rgba( 0 , 0 , 0 , 0.9 ); border-bottom: 3px solid white; padding: 1px; margin-bottom: 11px; padding-bottom: 10px;"&gt;'+d.year+' '+s.yearPrefix+'&lt;/div&gt;'+months +'&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;/div&gt;'; }, _GetDateAsString: function(date){ var s=state.AdvancedCalendar.setting; return s.daysOfTheWeek[AdvancedCalendar._GetWeekDayForDate(date)-1] + " - " +date.day + " " + s.monthsOfTheYear[date.month-1]["name"] + ', ' + date.year + ' ' +s.yearPrefix; }, ShowDate: function(d,options) { var opt=_.defaults((options||{}),{ showLunarPhases: true }); sendChat('','/direct ' +'&lt;div style="color: moccasin; font-weight: bold; font-family: Arial; text-align: center; padding: 10px; ' +'background: #333; border-radius: 10px; box-shadow: 2px 2px 3px 1px rgba(0,0,0,0.5); ' +'border: 4px solid #fff; font-size: 16px; margin: 0 10px;"&gt;' +AdvancedCalendar._GetDateAsString(d,opt) +' ' +AdvancedCalendar._GetPhaseForDate(d,opt) +AdvancedCalendar._GetSeasonForDate(d, opt) +AdvancedCalendar._GetWeatherForDate(d, opt) +AdvancedCalendar._GetHolidays(d, opt) +AdvancedCalendar._GetLogs(d, opt) +'&lt;/div&gt;' ); }, ShowDateAsWhisper: function(who, d, options) { sendChat('','/w GM ' +AdvancedCalendar._GetDateAsString(d,options) +' ' +WeatherRandomGenerator._GetWeatherAsString(AdvancedCalendar.GetWeather(d), options) ); }, ShowFutureDate: function(d, options) { var opt=_.defaults((options||{}),{ showLunarPhases: true }); sendChat('','/direct ' +'&lt;div style="color: moccasin; font-weight: bold; font-family: Arial; text-align: center; padding: 10px; ' +'background: #333; border-radius: 10px; box-shadow: 2px 2px 3px 1px rgba(0,0,0,0.5); ' +'border: 4px solid #fff; font-size: 16px; margin: 0 10px;"&gt;' +AdvancedCalendar._GetDateAsString(d,opt) +' ' +AdvancedCalendar._GetPhaseForDate(d,opt) +AdvancedCalendar._GetSeasonForDate(d, opt) +AdvancedCalendar._GetHolidays(d, opt) +AdvancedCalendar._GetLogs(d, opt) +'&lt;/div&gt;' ); }, ShowMonth: function(d,options){ var opt=_.defaults((options||{}),{ }); sendChat('','/direct '+AdvancedCalendar._GetMonthForDate(d,opt)); }, ShowYear: function(d,options){ var opt=_.defaults((options||{}),{ showYear: false }); sendChat('','/direct '+AdvancedCalendar._GetYearForDate(d,opt)); }, GoToDate: function(day, month, year) { var s = state.AdvancedCalendar.setting; if (month &lt; 1 || month &gt; 13) { return; } if (day &lt; 1 || day &gt; s.monthsOfTheYear[state.AdvancedCalendar.now.month-1]) { return; } state.AdvancedCalendar.now = { day : day, month : month, year : year }; }, HandleInput: function(tokens, msg, isGM){ var options = AdvancedCalendar._GetOptionsFromTokens(tokens); tokens=_.filter(tokens, function(tok){ return null == tok.match(/^--/); }); var cmd = tokens[0] || 'month'; switch (cmd) { /* Show the current month calendar */ case 'month': AdvancedCalendar.ShowMonth(state.AdvancedCalendar.now,options); break; /* Show the current year calendar */ case 'year': AdvancedCalendar.ShowYear(state.AdvancedCalendar.now,options); break; /* Show todays info in detail */ case 'today': AdvancedCalendar.ShowDate(state.AdvancedCalendar.now,options); break; /* Advance the current date by a number of days (1 of argument is ommited) */ case 'next': if (!isGM) return; var days=tokens[1] || 1; AdvancedCalendar.AdvanceDays(days); AdvancedCalendar.ShowDate(state.AdvancedCalendar.now,options); break; /* Go back a number of days (1 of argument is ommited) in the current date */ case 'prev': if (!isGM) return; var days=tokens[1] || 1; AdvancedCalendar.RemoveDays(days); AdvancedCalendar.ShowDate(state.AdvancedCalendar.now,options); break; /* Go to a specific date using the parameters according to DD MM YYYY */ case 'goto': if (!isGM) return; var day = parseInt(tokens[1]); var month = parseInt(tokens[2] || state.AdvancedCalendar.now.month); var year = parseInt(tokens[3] || state.AdvancedCalendar.now.year); AdvancedCalendar.GoToDate(day, month, year); AdvancedCalendar.ShowDate(state.AdvancedCalendar.now,options); break; case 'see': var day = parseInt(tokens[1]); var month = parseInt(tokens[2] || state.AdvancedCalendar.now.month); var year = parseInt(tokens[3] || state.AdvancedCalendar.now.year); var seedate = { day : day, month : month, year : year }; AdvancedCalendar.ShowFutureDate(seedate, options); break; case 'log': var mindex = msg.content.indexOf('-m '); if (mindex &lt;0) return; var logdata = msg.content.substring(mindex +3); log(logdata); AdvancedCalendar.AddLog(state.AdvancedCalendar.now, msg.who, logdata, false); break; case 'note': if (!isGM) return; var mindex = msg.content.indexOf('-m '); if (mindex &lt;0) return; var logdata = msg.content.substring(mindex +3); log(logdata); AdvancedCalendar.AddLog(state.AdvancedCalendar.now, msg.who, logdata, true); break; case 'weather': if (!isGM) return; AdvancedCalendar.ChangeWeather(state.AdvancedCalendar.now,options); AdvancedCalendar.ShowDateAsWhisper(msg.who, state.AdvancedCalendar.now, options) break; } }, RegisterEventHandlers: function() { on("chat:message", function (msg) { // Exit if not an api command if (msg.type != "api") return; // clean up message bits. msg.who = msg.who.replace(" (GM)", ""); msg.content = msg.content.replace("(GM) ", ""); var isGM = playerIsGM(msg.playerid); log(msg.content); var tokenized = msg.content.split(" "); var command = tokenized[0]; switch(command) { case "!cal": case "!calendar": { AdvancedCalendar.HandleInput(_.rest(tokenized), msg, isGM); } break; case "!s": { sendChat('', '/direct &lt;div style="border: 2px solid red;"&gt;&lt;b&gt;state.AdvancedCalendar&lt;/b&gt;&lt;br&gt;&lt;pre&gt;' +JSON.stringify(state.AdvancedCalendar,undefined," ").replace(/\n/g,'&lt;br&gt;') +"&lt;/pre&gt;&lt;/div&gt;" ); } break; case "!t": { AdvancedCalendar._GetWeekDayForDate(state.AdvancedCalendar.now); } break; } }); } }; on("ready",function(){ log("WeatherRandomGenerator - Version " + WeatherRandomGenerator.version); WeatherRandomGenerator.CheckInstall(); WeatherRandomGenerator.RegisterEventHandlers(); log("AdvancedCalendar - Version " + AdvancedCalendar.version); log("Installing " + CALENDAR.name + "..."); AdvancedCalendar.CheckInstall(CALENDAR); AdvancedCalendar.RegisterEventHandlers(); }); ArtonPlugin var ArtonCalendar = ArtonCalendar || { name: "Calendário Vandiomense", startingDate : { day: 7, month: 2, year: 1483 }, setting : { daysOfYear : 364, daysOfTheWeek: [ 'Dorag', 'Sagrag', 'Terag', 'Qarag', 'Qiirag', 'Sxerag', 'Sabrag'], monthsOfTheYear: [ {name:'Altossol', days: 28, season: 0}, {name:'Wynn', days: 28, season: 0}, {name:'Cyd', days: 28, season: 0}, {name:'Salizz', days: 28, season: 1}, {name:'Terraviva', days: 28, season: 1}, {name:'Dantal', days: 28, season: 1}, {name:'Luvitas', days: 28, season: 2}, {name:'Weez', days: 28, season: 2}, {name:'Exinn', days: 28, season: 2}, {name:'Lunaluz', days: 28, season: 3}, {name:'Pace', days: 28, season: 3}, {name:'Aurea', days: 28, season: 3}, {name:'Crya', days: 28, season: 4} ], yearPrefix: 'CA', seasons : [ "Primavera", "Verão", "Outono", "Inverno", "Priverinou" ], }, holidays : { "9/1" : [ { name: "Dia do Reencontro: Solsticio de Verão", area: "", description: "... " +"Solsticio de Verão " }, ], "12/2" : [ { name: " Cerimônia de Admissão da Ordem da Mãe referente ao verão", area: "", description: "" }, ], "9/4" : [ { name: "Dia do Duelo: Equinócio de Outono", area: "", description: "" }, ], "9/4" : [ { name: "Noite Longa: Solsticio de Inverno", area: "", description: "" }, ], "9/7" : [ { name: "Dia do Duelo: Equinócio de Outono", area: "", description: "" }, ], "9/10" : [ { name: "Dia da Alegria: Equinócio de Primavera", area: "", description: "" }, ], "9/13" : [ { name: "Dia do Recomeço: Equinócio de Primavera", area: "", description: "" }, ], }, }; CALENDAR = ArtonCalendar; Any ideas? Thanks
1626439294
About the changes not updating, just found an answer from The Aaron 7 years ago and it worked. I just needed to change the version on the script: change version: 1.0 to version: 1. 1 , It resets the calendar on next API restart. Great!!! Now just the weather function. Any ideas?
1626443334
When I use !cal next it changes to the next day and shows the correct formatting of weather. Just when I use !cal weather that he doesn't show the correct formatting. So I am guessing only the function to change weather is not working correctly, specifically when it try to show the result of the change. It changes the weather but show it as bellow: Dorag - 22 Wynn, 1483 CA cold - When it should show:
1626443351
1626444722
Soooooo. Just changed some line and it seems to be almost working. So at it turns out the change weather is a function that shows the new weather only to the gm using&nbsp;ShowDateAsWhisper. So I changed ShowDateAsWhisper to look just like ShowDate from ShowDateAsWhisper: function(who, d, options) { sendChat('','/w GM ' +AdvancedCalendar._GetDateAsString(d,options) +' ' +WeatherRandomGenerator._GetWeatherAsString(AdvancedCalendar.GetWeather(d), options) ); to ShowDateAsWhisper: function(who, d, options) { sendChat('','/w GM ' +'&lt;div style="color: moccasin; font-weight: bold; font-family: Arial; text-align: center; padding: 10px; ' +'background: #333; border-radius: 10px; box-shadow: 2px 2px 3px 1px rgba(0,0,0,0.5); ' +'border: 4px solid #fff; font-size: 16px; margin: 0 10px;"&gt;' +AdvancedCalendar._GetDateAsString(d,options) +' ' //+WeatherRandomGenerator._GetWeatherAsString(AdvancedCalendar.GetWeather(d), options) +AdvancedCalendar._GetWeatherForDate(d, options) ); I guess the post can be closed
1626445829
New problem. When I use !cal weather it only brings cold weathers. Its almost as if when I use ChangeWeather it changes the climate from Temperate to Cold. I am trying to implement in ChangeWeather a line to show current Climate. Couldn`t find in it if it is changing climate
1626448271
yep you can close this. Did some gimmicks and it is working now
1626448394
Changed from ChangeWeather: function(date) { var dateId = (AdvancedCalendar._GetTotalDaysForDate(date)).toString(); var sched = state.AdvancedCalendar.schedule; if (_.has(sched, dateId) &amp;&amp; _.has(sched[dateId], "weather")) { sched[dateId]["weather"] = WeatherRandomGenerator.GenerateWeather(season); } else { var s = state.AdvancedCalendar.setting; var season = s.monthsOfTheYear[date.month -1].season; log(season); var w = WeatherRandomGenerator.GenerateWeather(season); sched[dateId] = {}; sched[dateId]["weather"] = w; } }, ChangeWeather: function(date) { var dateId = (AdvancedCalendar._GetTotalDaysForDate(date)).toString(); var sched = state.AdvancedCalendar.schedule; if (_.has(sched, dateId) &amp;&amp; _.has(sched[dateId], "weather")) { //sched[dateId]["weather"] = WeatherRandomGenerator.GenerateWeather(season); var s = state.AdvancedCalendar.setting; var season = s.monthsOfTheYear[date.month -1].season; log(season); var w = WeatherRandomGenerator.GenerateWeather(season); sched[dateId] = {}; sched[dateId]["weather"] = w; } else { var s = state.AdvancedCalendar.setting; var season = s.monthsOfTheYear[date.month -1].season; log(season); var w = WeatherRandomGenerator.GenerateWeather(season); sched[dateId] = {}; sched[dateId]["weather"] = w; } }, Ijust changed ChangeWeather if and else to be the same. I know. It is a monster, but it works. Don`t know why.hahahaha. I guess the post can be closed
1626453903
The Aaron
Forum Champion
API Scripter
Great, glad you got it worked out!