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

[Request] Calendar Script.

Good day all, I was recently thinking about adding a Calendar script to my game to help keep track of days, but, in my excitement of being able to solve the logical problems of how such a script would work, I completely forgot I didn't know how to script. So, I have come to you, asking for a bit of assistance. I do not require the entire script, just some pointers on how to start, and if my idea is possible. If not, can you point me in a more correct direction? My world has 10 months, each with 35 days. This is how I figured I would code it if I knew how to work with Javascript: (Psuedocode) var day = 1 on receiving input, day = day + input if day > 350, day = day-350 on query, month = floor.(day/35), dayout = day-(month*35) if dayout = 0, dayout = 35 var str daystr = "dayout+(long IF statement to align st/nd/rd/th endings)" if month = 1, output = "daystr" + " of The Month of Mist" if month = 2, ect, ect. I would preferably have a "Check day" and an "Adjust Day" input command, although adjusting by 0 would work as well I suppose. Anyone willing to design/point me in the right direction on how to design this script for me? Cheers, Shannon Pasco.
1464792698
The Aaron
Pro
API Scripter
I wrote one a while ago (actually, my first released script). &nbsp;It's a little rough, but you could look at it for inspiration: &nbsp; <a href="https://app.roll20.net/forum/post/907343/script-my" rel="nofollow">https://app.roll20.net/forum/post/907343/script-my</a>... You could certainly take the ord() function for calculating st/nd/rd/etc. Also, look into the modulus operator: % 13 % 6 = 1 12 % 6 = 0 11 % 6 = 5 Very handy for fitting numbers in a range. Definitely ask more questions!
Well, I certainly learnt a lot from your script Aaron, cheers. Although it may disappoint you that I modified your script instead of writing my own based on yours, but thank you very much for pointing me in the right direction. I looked through your code, realized I had nowhere near enough understanding of Javascript to begin to write my own, and started reading yours to find where I needed to change things to fit my own calendar. Rest assured, I certainly learnt a lot from your code. I struggled for a while trying to find where the text output strings were, and after that, I kept getting 12 months when I used !cal year, and it took quite a while to find where that was coming from. &nbsp;- Mission complete. (Minus a slight string output change made after screenshot was taken) Thank you so much Aaron!
1464804752
The Aaron
Pro
API Scripter
I'm flattered, not disappointed. =D &nbsp;I'm glad you were able to use it to get what you wanted, and certainly if you don't want to get into the business of script writing, I'm happy to help save you time achieving your goals! &nbsp;=D Definitely let me know if you have any other questions! &nbsp;=D
1464898535

Edited 1464898586
I've been&nbsp;hacking your script too. I haven't finished it yet, but here are some modifications I did. I've separated the "Calendar Engine" from the "Calendar Definition". This way someone could create or modify the calendar definition with ease. Added support for non-homogeneous calendars. Like months with different number of days, like golarions's calendar or our own gregorian's calendar. However I haven't bother myself with leap years. I kept the moon phase and added seasons and weather. The weather is automatically generated using Pathfinder rules (I plan to allow the GM to set the weather in advance) Holidays announcement. Holidays are defined in the calendar definition. Schedule things, like setting when something will happen, both by GM and players. (however this is not working properly yet) Here are some screenshots:
1464900979
The Aaron
Pro
API Scripter
Very awesome! &nbsp;I have a similar version I was writing... (2 years ago?). &nbsp;You should definitely share the finished product!
Please do share! I wouldn't mind that :O. I currently still use Aarons Calendar script and its been super helpful!
Oh wow&nbsp;Fallyrion! Thats some pretty cool stuff! I really like the weather and events improvements. Would love to see a completed version of this! Good work.
I will share it. I hope I could finish it on this weekend.
1464979784
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Oh, I'm looking forward to that. Nice job Fallyrion.
1465693264

Edited 1465693437
These look amazing. Fallyrion the weather looks so cool, do players have access to show it or the GM only?
1466220730
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Fallyrion, any word on your calendar/weather awesomeness?
Hey, I was wondering if you happened to have any progress to show or give out Fallyrion. :)
Now that Fallyrion calendar would be what I need :) Hope you have luck / skill to finish it. I'm sure are not skilled enough for that kind of work.
Fallyrion, Any status on progression toward a release of your calendar? &nbsp;Even in the current (beta?) incarnation that you posted, I'd welcome using it in my game. &nbsp;Hope you haven't abandoned the project as it's something I've been checking back on frequently with a bit of bated breath.
Sorry guys,&nbsp;I forgot to follow this post, so I was not aware of your replies. I haven't worked much on the script since my last post, I've started a RPG streaming channel and it is taking about all my freetime. However I just did organized my code a bit, solved some bugs and uploaded it to the GitHub. I plan to offer a better User Interface, this is my next goal with the script. <a href="https://github.com/caioviel/roll20scripts/tree/mas" rel="nofollow">https://github.com/caioviel/roll20scripts/tree/mas</a>...
You're the best!
Thank you so much Fallyrion!
Thx, I'll test it out later today :D Realy exited already.
If you guys found some bug, please report.
1471074497

Edited 1471078456
I have a few questions. I love the feature to add notes to days and such. But where can I find those entries? I mean, where is the storage database, or location to get an overview of all notes that I have added. Same goes for holidays, where is the database / location to get on overview of what days have what kinds of holiday / events? How can notes be erased? How can I offset the gregorian calendar? Currently, it's a Thursday but I need it to be a Sunday. My offset would be 3 days. Oh and my weekday list begins on a Monday and ends with a Sunday, just as a sidenote :D -&gt; found it :D Line 699 var firstWeekDay = AdvancedCalendar._GetWeekDayForDate(mday)+3; Adding a +3 did the offset for my calendar :D BUT this only works for !cal month and !cal year.... the moment I use !cal today it shows the day name which it would be, without the offset. I guess my solution did only work 50% :(
The notes are showed when via the today command (when it is the current day) or you o !cal see &lt;DD&gt; &lt;MM&gt; &lt;YYYY&gt;. I will add more commands to handle this, like show the days a weak or mounth which have some note on them. The holydays are on the plugins files. Golarion's Calendar is the only one I've added the holydays. You can see how the golarion calendar handle this and extend the plugins for the other calendars (please, share with me if you did =). Notes cannot be erased right now. I need to work more on this. This problem with gregorian is because I haven't considered leap year. Implemeting leap year is complicated because each calendar has its own rules for it. One way to offset it for gregorian is to change the function&nbsp; _GetTotalDaysForDate. &nbsp;Try to change the line 491 to: return totalDays+3; I haven't tried it myself, but I guess it will work
Thanks for the info... I found the holiday part in the calendar section. And also thanks for the rest, all works fine for now.
Hi Fallyrion, thanks again for taking the time to work on the calendar script, it's a much needed resource :) I had some time today to get it setup and tinker around with it a bit, but I do have a few questions when you have some time. Note: I have both the Advanced Calendar and ForgottenCalendar scripts enabled I used the Golarion calendar holiday code as a template for inputting a few of the Forgotten Realms holidays, but they aren't showing up when I call it using your command&nbsp; !cal see dd mm yyyy. &nbsp;The following is the holiday code in the ForgottenCalendar script in case I'm screwing something up. I'm also assuming that "1/1" = "dd/mm". &nbsp; &nbsp; holidays : { &nbsp; &nbsp; &nbsp; &nbsp; "1/1" : [ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: "Seeing Justice",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; area: "Tyr",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description: "" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: "Thunder Blessing", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; area: "Moradin", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description: "" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; ], &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "10/1" : [ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: "Great Clang",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; area: "Gaerdal",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description: "" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; ], &nbsp; &nbsp; &nbsp; &nbsp; "1/2" : [ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: "Seeing Justice", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; area: "Tyr", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description: "" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; ], &nbsp; &nbsp; &nbsp; &nbsp; "1/3" : [ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: "Seeing Justice", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; area: "Tyr", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description: "" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; ], &nbsp; &nbsp; &nbsp; &nbsp; "1/4" : [ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: "Queen's Gambit", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; area: "Red Knight", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description: "" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; ], &nbsp; &nbsp; &nbsp; &nbsp; "1/5" : [ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: "Unwrapping", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; area: "Geb", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description: "" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; ] &nbsp; &nbsp; } For daysOfTheWeek, I removed the numbers from the ForgottenCalendar script but it still shows up as "1", "2", "3", etc. Do I need to change something in the Advanced Calendar script as well? Is there a way to decrease the size of the season icon? If you need any further information please let me know, thanks!
1471229071

Edited 1471240676
Greetings, First off, thank you for sharing this amazing Calendar script. I seem to have an issue however. I installed the GolarionCalendar script, and edited to my own homebrew calendar, but whenever I call upon !cal today, it returns me the Golarion days, even though they no longer exist in code. I frankly do not know how this is even possible. Does anyone have any insight? More odd, is that it works when added to a new campaign... just my current one does not work in the slightest... Will try copying everything across and seeing if it will work. It is now working. Copying into a new campaign worked, I don't know why the main one failed... Ah well. Scrap that. Only what is put in initially carries over, no changes after that can be made without deleting and redoing the script. Is there a way to force it to refresh the plugin code? Thank you again!
1471352768

Edited 1471523568
Shannon P. said: Scrap that. Only what is put in initially carries over, no changes after that can be made without deleting and redoing the script. Is there a way to force it to refresh the plugin code? Thank you again! On line 15 280 of AdvancedCalendar.js version :1.0, Change this version to a different number and it will force reinstalling the script from zero. Edit 1: changed the line number, thank you Shannon P. to point out my mistake,
Syns said: I used the Golarion calendar holiday code as a template for inputting a few of the Forgotten Realms holidays, but they aren't showing up when I call it using your command&nbsp; !cal see dd mm yyyy. &nbsp;The following is the holiday code in the ForgottenCalendar script in case I'm screwing something up. I'm also assuming that "1/1" = "dd/mm". I've just copied your code and put in my Forgotten plugin and it worked pretty well. I'm not sure on why it doesn't work for you. Anyway, I've commited the modified Forgotten plugin on github. Syns said: For daysOfTheWeek, I removed the numbers from the ForgottenCalendar script but it still shows up as "1", "2", "3", etc. Do I need to change something in the Advanced Calendar script as well? I believe you need to change the Calendar Version to force a refresh on the Advanced Calendar. See previous post to Shannon P. Syns said: Is there a way to decrease the size of the season icon? It's possible, but I'm not able to give you a full answer to that because, frankly, I really suck at CSS. A friend helped me on creating the CSS to this script. But the season images are defined between lines 583 and 587.
Thank you&nbsp;Fallyrion! Although, the version for the calendar itself is on line 280. The one on line 15 is for the Random Weather Generator.
Thank you, I'll definitely grab the updated plug in tomorrow and try it out! Will use the change version method as well. Won't have time to mess with the season images until the weekend more than likely, if I'm able to achieve the desired effect I'll let you know :)&nbsp;
Is there a way to not have it repeat the date at the beginning of the output?&nbsp; Here, I'll show you what I mean: Instead of "4-4", I'd like for it to just say "4 Flamerule,...." EDIT: Oh, I see, that first "4" is supposed to be the days of the week.&nbsp; Are they not named in the Forgotten Realms calendar? EDIT 2: Also, I'm getting some weird weather stuff - like a low of -18 celsius in summer.&nbsp; That seems a little off. Are the Pathfinder weather generation rules that capricious, or is there something off in the script? EDIT 3: also - is there a way to adjust when in the month the full moon occurs?
1471483161

Edited 1471483219
Gozer the Gozerian said: Is there a way to not have it repeat the date at the beginning of the output?&nbsp; Here, I'll show you what I mean: Instead of "4-4", I'd like for it to just say "4 Flamerule,...." EDIT: Oh, I see, that first "4" is supposed to be the days of the week.&nbsp; Are they not named in the Forgotten Realms calendar? EDIT 2: Also, I'm getting some weird weather stuff - like a low of -18 celsius in summer.&nbsp; That seems a little off. Are the Pathfinder weather generation rules that capricious, or is there something off in the script? EDIT 3: also - is there a way to adjust when in the month the full moon occurs? Per the PHB "Individual days of a tenday have no special names. Instead, they are denoted by counting from the beginning&nbsp;of the period (" first day," "second day," and so on)." &nbsp;You can change that info in the ForgottenPlugin.js though when you bring up the month and year view it will cut off after the second character. I do see some code for the lunar phases under _GetPhaseForDate &nbsp;if you'd like to tinker around with it :) I'm happy with the default settings but it definitely would be a "nice to have" feature of being able to adjust that.
Gozer the Gozerian said: EDIT 2: Also, I'm getting some weird weather stuff - like a low of -18 celsius in summer.&nbsp; That seems a little off. Are the Pathfinder weather generation rules that capricious, or is there something off in the script? This is probably a bug,I will look at it on the weekend. This happens very often? I will add some commands to personalize the script, like change the metrical system to the imperial system, change de climate (there are 3 options, but actually you need to change it on the script itself).&nbsp; The moon phase shift was something that I didn't antecipate, you I'll try to add.
Fallyrion said: The moon phase shift was something that I didn't antecipate, you I'll try to add I was actually looking at that a bit late last night, the faerun calendar uses 8 phases for its moon, <a href="http://archive.wizards.com/dnd/fc/phases.htm" rel="nofollow">http://archive.wizards.com/dnd/fc/phases.htm</a>, vs the 7 phases that are present. I still won't have a chance to tinker with it until this weekend, but just wanted to give a heads up : )
Fallyrion said: Gozer the Gozerian said: EDIT 2: Also, I'm getting some weird weather stuff - like a low of -18 celsius in summer.&nbsp; That seems a little off. Are the Pathfinder weather generation rules that capricious, or is there something off in the script? This is probably a bug,I will look at it on the weekend. This happens very often? It was just happening on that one day for some reason.&nbsp; I forced the script to reinstall by changing the version number as mentioned earlier in this thread, and that seems to have fixed it.
1471546776
The Aaron
Pro
API Scripter
Syns said: Fallyrion said: The moon phase shift was something that I didn't antecipate, you I'll try to add I was actually looking at that a bit late last night, the faerun calendar uses 8 phases for its moon, <a href="http://archive.wizards.com/dnd/fc/phases.htm" rel="nofollow">http://archive.wizards.com/dnd/fc/phases.htm</a> , vs the 7 phases that are present. I still won't have a chance to tinker with it until this weekend, but just wanted to give a heads up : ) There are 28 phases in the image for the moon in the original Mystara Calendar script that this is based on. &nbsp;7 columns by 4 rows: You could certainly consider each to fall in one of those 8 classifications though, and even print them next to the image. &nbsp; Really, the first column from top to bottom is "New Moon", "First Quarter", "Full Moon", "Last Quarter". &nbsp;The 6 columns to the right on each row from top to bottom are "Waxing Crescent","Waxing Gibbous", "Waning Gibbous", "Waning Crescent". &nbsp;The first column are basically the balance points and are precise single events, whereas the others are transitional phases that last between the others.
So sorry to resurrect an old thread... but silly question... Is there an easy way to represent the output in Fahrenheit and Miles Per hour instead of Celsius? &nbsp;
Yes there is, but I don't remember offhand what you need to do - it's either changing a line of code, or a configuration menu vim on my phone now, but I'll look into it a bit later, if no one else has.&nbsp;
I think the line of code you're looking for is line 25 (at least on my copy of the script it is), and you want to set it to: useMetricalSystem : false That should change it over to standard English measurements.&nbsp; It's probably set to "true" in your version of the script.
Thanks Gozer! &nbsp;
I'm not able to get the note function to work - I set a note, but it doesn't show when I go back to the date.&nbsp; Is this functionality working?