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

[Script] Calendar - Simple way to keep track of the current in-game date.

1622124535

Edited 1622978611
Steve
Pro
API Scripter
I kept forgetting the in-game date and it became a problem with the timing of events, so I created a simple calendar script to help keep track of the current in-game date:&nbsp; <a href="https://gist.github.com/sgaxr/b0eb9950dc161a883d4efc697a58e56f" rel="nofollow">https://gist.github.com/sgaxr/b0eb9950dc161a883d4efc697a58e56f</a> Here's the readme: Calendar This simple script is used to help keep track of the current in-game date for your game. It was designed to be extremely simple to use and update. It currently supports 4 calendars: gregorian &nbsp;- the calendar used in (most of) the real world. harptos &nbsp;- the calendar used in the Forgotten Realms (12 months of 30 days, with 5 extra days between months and a sixth extra day every 4 years). barovian &nbsp;- the lunar calendar used in Barovia (12 months of 28 days). golarion &nbsp;- the Golarion calendar used in Pathfinder (similar to the Gregorian calendar with different names, but leap years are every 8 years) Setup Once this script is installed in your game, setup is easy. First, set the type of calendar you want to use (in this example, I'll use harptos): !cal type harptos Secondly, set the date, which goes&nbsp; day month year : !cal set 20 1 1491 Since the harptos calendar has days that fall between months, you can also use the name of that day and the year: !cal set midsummer 1490 !cal set feastofthemoon 1490 !cal set Feast of the Moon 1490 Usage Once the calendar has been set up, it's pretty easy to use. Display To see the current date (this command is available to everyone): !cal Increment Day To make the calendar go to the next day (GM only command), use: !cal next Decrement Day If you incremented the day by accident or too many times, you can always go back (GM only command) using this: !cal previous Full API Calendar Version 1.2 !cal (everyone) &nbsp;Displays the current in-game date. Aliased by:&nbsp; !cal display !cal next (GM) &nbsp;Advances the in-game date by 1 day. Aliased by:&nbsp; !cal ++ ,&nbsp; !cal increment !cal add [number of days] (GM) &nbsp;Advances the in-game date by a given number of days. [number of days] (integer (positive)) - the number of days to advance the date by Aliased by:&nbsp; !cal += [number of days] ,&nbsp; !cal set +[number of days] !cal subtract [number of days] (GM) &nbsp;Decreases the in-game date by a given number of days. [number of days] (integer (positive)) - the number of days to decrease the date by Aliased by:&nbsp; !cal -= [number of days] ,&nbsp; !cal set -[number of days] !cal previous (GM) &nbsp;Regresses the in-game date by 1 day. Aliased by:&nbsp; !cal -- ,&nbsp; !cal prev ,&nbsp; !cal decrement !cal system (everyone) &nbsp;Displays the current calendar system. Aliased by:&nbsp; !cal type !cal system [system] (GM) &nbsp;Sets the current calendar system. The date may need to be set again after using this command. [system] (text) - the calendar system, one of: gregorian, harptos, barovian, golarion Aliased by:&nbsp; !cal type [system] !cal set [day] [month] [year] (GM) &nbsp;Sets the current in-game date. [day] (integer) - the day of the month (usually 1-31) [month] (integer|text) - the month in the year (usually 1-12), or the name of the month (e.g. January) [year] (integer) - the year !cal set [special day] ([year]) (GM) &nbsp;Sets the current in-game date using the name of a day that falls between months, such as with the Harptos calendar. [special day] (text) - the name of the special day, with or without spaces (e.g. Feast of the Moon, feastofthemoon) [year] (optional, integer) - the year !cal set &lt;+-&gt;[number of days] (GM) &nbsp;Depending on whether you prepend a + or a - to the number, adds or subtracts a number of days from the current in-game date. [number of days] (integer) - the number of days to add or subtract from the current in-game date Aliased by:&nbsp; !cal add [number of days] ,&nbsp; !cal += [number of days] ,&nbsp; !cal subtract [number of days] ,&nbsp; !cal -= [number of days] !cal whisper [whisper mode] (GM) &nbsp;Turns GM whisper mode on or off. If on, only the GM can use the calendar script to see the current date. [whisper mode] (on|off|toggle) - on turns on GM whisper mode, off turns off GM whisper mode, toggle toggles GM whisper mode !cal help (everyone) &nbsp;Displays this help message.
1622124945
The Aaron
Forum Champion
API Scripter
Nice addition!&nbsp; I've always wanted to write a better calendar script, but time is ever fleeting.&nbsp; This looks neat!
1622125496
Nice. Looks pretty similar to this calendar script , but more streamlined.
1622127748

Edited 1622127853
Steve
Pro
API Scripter
Jarren K. said: Nice. Looks pretty similar to this calendar script , but more streamlined. I had no idea that script existed! :O I do like the simplicity of mine though. I made a macro button that calls the next day function, so it's easy to do when the players take a long rest:&nbsp;&nbsp;
1622211524
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Nice implementation. I usually prefer to play fast and loose with the date and time passage, but I might give this a try.
1622291847

Edited 1622292476
When I issue the command "!cal set Midsummer", I get an error. In fact, trying to set the date (such as "!cal 1,2,1490") gets the same error (From Calendar [error]): &nbsp; (GM) Calendar [error]: &nbsp; Usage: !cal set&nbsp; [day] ,&nbsp; [month] ,&nbsp; [year] &nbsp;where&nbsp; [day] &nbsp;is an integer from 1-30,&nbsp; [month] &nbsp;is an integer from 1-12, and&nbsp; [year] &nbsp;is an integer. !cal set&nbsp; [day] (,&nbsp; [year] ) &nbsp;where&nbsp; [day] &nbsp;is a special day in the list 'Midwinter', 'Greengrass', 'Midsummer', 'Shieldmeet', 'Highharvestide', 'Feast of the Moon', and (optional)&nbsp; [year] &nbsp;is a valid integer.
1622304450
Saul J. said: When I issue the command "!cal set Midsummer", I get an error. In fact, trying to set the date (such as "!cal 1,2,1490") gets the same error It looks like the script is set to read the !cal messages and split arguments on a space (" "), so make sure you're not using any commas (even though the help text appears to use commas).&nbsp; It also appears that the 'special days' still need a year, so make sure you include that when setting that date. !cal set Midsummer 1490 !cal 31 6 1490 Either of those commands should set the date as Midsummer 1490.
1622345487
Steve
Pro
API Scripter
Saul J. said: When I issue the command "!cal set Midsummer", I get an error. In fact, trying to set the date (such as "!cal 1,2,1490") gets the same error (From Calendar [error]): &nbsp; (GM) Calendar [error]: &nbsp; Usage: !cal set&nbsp; [day] ,&nbsp; [month] ,&nbsp; [year] &nbsp;where&nbsp; [day] &nbsp;is an integer from 1-30,&nbsp; [month] &nbsp;is an integer from 1-12, and&nbsp; [year] &nbsp;is an integer. !cal set&nbsp; [day] (,&nbsp; [year] ) &nbsp;where&nbsp; [day] &nbsp;is a special day in the list 'Midwinter', 'Greengrass', 'Midsummer', 'Shieldmeet', 'Highharvestide', 'Feast of the Moon', and (optional)&nbsp; [year] &nbsp;is a valid integer. Ah, yeah, like Jarren said, it looks like the special days still need the year even though I documented it as not needing the year. I'll fix that so that the year is actually optional. Thanks for finding that!
1622387020
Steve
Pro
API Scripter
Alright, I've updated the gist so that the special day no longer requires the year.
1622417392
Steve
Pro
API Scripter
I've just updated the script again. The code is a little better on this one in my opinion (though still not great, lol), and it will be easier to add new calendars to it. The main difference is the `!cal help` command that displays the syntax in chat, and the `!cal set` command is now able to recognize the names of the months (e.g. `!cal set 7 April 2136`). I'll post again when I add some new calendars (Golarion is next).
1622424193
Now getting the following: Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your script's code and click the "Save Script" button. We will then attempt to start running the scripts again.&nbsp; More info... &nbsp;If this script was installed from the Script Library, you might find help in the Community API Forum. For reference, the error message generated was:&nbsp; TypeError: Cannot read property 'who' of undefined TypeError: Cannot read property 'who' of undefined at SEJ_Calendar_App.error (apiscript.js:18445:47) at SEJ_Calendar_App.process (apiscript.js:18308:14) at apiscript.js:18480:15 at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:154:1), &lt;anonymous&gt;:65:16) at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:154:1), &lt;anonymous&gt;:70:8) at /home/node/d20-api-server/api.js:1708:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489)
1622434270

Edited 1622434299
Steve
Pro
API Scripter
Saul J. said: Now getting the following: Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your script's code and click the "Save Script" button. We will then attempt to start running the scripts again.&nbsp; More info... &nbsp;If this script was installed from the Script Library, you might find help in the Community API Forum. For reference, the error message generated was:&nbsp; TypeError: Cannot read property 'who' of undefined TypeError: Cannot read property 'who' of undefined at SEJ_Calendar_App.error (apiscript.js:18445:47) at SEJ_Calendar_App.process (apiscript.js:18308:14) at apiscript.js:18480:15 at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:154:1), &lt;anonymous&gt;:65:16) at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:154:1), &lt;anonymous&gt;:70:8) at /home/node/d20-api-server/api.js:1708:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) Hey Saul, it looks like I had forgotten to set a variable on a specific error. I've fixed it and updated the gist. Thanks for letting me know about this! Edit to add: The Golarion calendar has also been added. :D
1622465223
Ok, now everything appears to be working correctly, except, you write in the help for the "set" command: [month] &nbsp;(integer|text) - the month in the year (usually 1-12), or the name of the month (e.g. January) But, "!cal set 11 Elient 1490" doesn't work.&nbsp; It doesn't recognize the name of the month. It knows the name of the month when displayed though.&nbsp; As a suggestion for possible improvement, what about an "add" function so you can set the date to some start date and then do "!cal set +5" or something similar?&nbsp; For example, to set the correct date for my current game, I had to calculate the number of days from the start date of the game to enter the current date. In other words, we've gone about 220 days in the game so I had to set it to the first of the year and then manually count the number of days. I would have been easier to do something like "!cal set +220".
1622591942
Steve
Pro
API Scripter
Saul J. said: Ok, now everything appears to be working correctly, except, you write in the help for the "set" command: [month] &nbsp;(integer|text) - the month in the year (usually 1-12), or the name of the month (e.g. January) But, "!cal set 11 Elient 1490" doesn't work.&nbsp; It doesn't recognize the name of the month. It knows the name of the month when displayed though.&nbsp; As a suggestion for possible improvement, what about an "add" function so you can set the date to some start date and then do "!cal set +5" or something similar?&nbsp; For example, to set the correct date for my current game, I had to calculate the number of days from the start date of the game to enter the current date. In other words, we've gone about 220 days in the game so I had to set it to the first of the year and then manually count the number of days. I would have been easier to do something like "!cal set +220". Gah, I do have that working, but it doesn't look like I've updated the gist with it. I should be able to add a command to add the days on. I might have some time later today or tomorrow to work on stuff, I'll let you know when I've updated things. Thanks for helping me iron this thing out! :D
This is a much more reliable way to track dates than how I've been doing it, I'm glad you added the Golarion calendar =D I like Saul's suggestion of a "!cal set +[days]" command, it would be very useful for skipping ahead multiple days during downtime.
1622874645
Steve
Pro
API Scripter
Saul, Persephone, thanks for the feedback! I've just updated the gist to include the month fix as well as new commands for adding or subtracting a given number of days: Adding days: !cal add [number of days] !cal set +[number of days] !cal += [number of days] Subtracting days: !cal subtract [number of days] !cal set -[number of days] !cal -= [number of days]
1622896742
Ok, much better. :-) "!cal set 1 Hammer 1490" worked perfectly.&nbsp; The next command I tried was "!cal set +229" which made it the 17th of Eleasis which is also correct. At first I thought it was wrong because I had forgotten about the days between some months. I'm glad you remembered them. :-) Testing also shows that you remembered the leap year too so that's great! Thank you! Steve said: Saul, Persephone, thanks for the feedback! I've just updated the gist to include the month fix as well as new commands for adding or subtracting a given number of days: Adding days: !cal add [number of days] !cal set +[number of days] !cal += [number of days] Subtracting days: !cal subtract [number of days] !cal set -[number of days] !cal -= [number of days]
1622897666
Now, one final request. Can you add a "GM only" option? This is useful because when characters are in a dungeon underground, they would not know the passing of days as accurately as if they were outside and could see sunrise/sunset. Or, something else might have occurred in-game (such as being captured and unconscious) where they would not know how many days had passed. If the GM is tracking the days using the API, the players should not see when the date changes if there is a reason for them not to know the passing of days.
1622978697
Steve
Pro
API Scripter
I was actually already working on that. Great minds think alike! It has been added to the gist.