1 Attachment(s)
Fantasy Grounds Custom Calendar Tutorial
I have seen a number of posts asking for help with creating custom calendars. I have tried to go through the forums and pull together all the gathered wisdom from many different posts and I have put together a custom calendar tutorial.
The attached tutorial gives an overview of creating a calendar, covering both the XML definition within the module file, and the optional LUA code in an extension. I have included 6 working examples with their respective files and compiled modules/extensions. I have tried to provide some documentation within both the sample XML and LUA files to make things easy to understand. I would appreciate any comments or improvements.
Also, huge credit goes out to user Andraax for all his calendar posts. A huge amount of what I learned was by going through those examples.
Included Examples
Example 1 - simple calendar, no holidays
----------------
First sample calendar has only a mod file and no accompanying extension. This is because it is a very simple calendar requiring no additional calculations.
Calendar basics
The Example 1 calendar has
7 months.
Each month has 28 days (4 weeks)
Each week has 7 days.
So, due to the simple math, each month looks exactly the same as every other month. The first day of the Month is the first day of the the week. There are no leap years.
Example 2
----------
The same calendar as Example 1 except with holidays added.
Example 3
-------------
Example Calendar 3 is a simple calendar consisting of 12 months. Odd months have 30 days, and even months have 31 days. There are no leap years.
In order for FG to know what day of the week a month starts, an extension is included with the LUA code to calculate that.
Example 4
-----------
Example 3 is the default Gregorian calendar as defined in the CoreRPG with some code comments added in with explanations.
The Gregorian calendar has months of varying length from 28-31 days, and has leap years. So the example includes the extension code which calculates both the day of the week properly, and calculates the number of days to add to the leap year.
Example 5
---------
An excellent example calendar from a user on the FG forums
Example 6
----------
A modified version of the traveller calendar, showing how to modify/format the day and date display
https://forge.fantasygrounds.com/shop/items/1612/view
I have added the Generic Day Handler Extension to the Forge for auto updating.
This extension will roll over days of the week as long as you dont have leap years. you can enable it in your calendar by using this as your lunar day calendar by adding
Code:
<lunardaycalc type="string">LunarWrap</lunardaycalc>