PDA

View Full Version : Fantasy Grounds Custom Calendar Tutorial



mattekure
February 11th, 2019, 21:48
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

<lunardaycalc type="string">LunarWrap</lunardaycalc>

damned
February 12th, 2019, 00:48
Great work mattekure

mattekure
February 12th, 2019, 03:37
Added a new example. The new example shows a modified version of the traveller calendar and demonstrates how you can modify how the calendar formats its day entries, and how you can change the formatting of the calendar date output to the chat.

ThatsSoNoc
February 29th, 2020, 13:31
Hi,

I have used your Georgian Calendar (modified - Leap Years and Leap Days) as the basis upon which I have skinned my custom calendar - changing the names of the days of the week, months of the year, and adding liturgical holidays in keeping with various custom pantheons.

However, I am unable to figure out how to create (code) a 'holiday' notation, that will appear on the calendar, which is fixed to a particular day of the week - E.G. Every Wednesday is Farmer's Market Day - and not to a numerical date of a month. Because the numerical date of each Wednesday shifts over time, back and forth, thus Wednesdays in a month do not always occur on that same numerical date, month after month, year after year?

Secondly, is there a means to fix a holiday to a specific day of the month, and have it reoccurring yearly, or possibly monthly, regardless of the actual numerical date - E.G. The second Sunday of every month (or the second Sunday of the third month) is St. Cuthburt's Day?

Finally, and quite possibly the hardest (impossible ?) request - can you set a holiday to occur, based on the lunar cycle calendar - similar to how Easter and Ramadan holidays are set from year to year? E.G. The first full moon of the year? Or the second crescent moon of the year? And so forth.

Thank-you for your suggested coding.

mattekure
February 29th, 2020, 14:12
Unfortunately, holidays are defined in the XML and cannot be defined programatically in code. So they will be fixed. Its not possible to have a holiday that always falls on a specific day of the week or changing the recurrence like that.

yeknom
March 7th, 2020, 10:45
Hi there Mattekure! Thanks for this. It has helped me tremendously.

If I wanted to add a holiday every 2 weeks using the example 2 from above would I have to have a period of 14 days then a holiday and then another period of 14 days with both periods have the same name month?

GunnarGreybeard
March 7th, 2020, 16:03
It's been a long while since I messed with a new calendar. This will come in handy when I go to relearn how to do it.

mattekure
March 7th, 2020, 16:49
Hi there Mattekure! Thanks for this. It has helped me tremendously.

If I wanted to add a holiday every 2 weeks using the example 2 from above would I have to have a period of 14 days then a holiday and then another period of 14 days with both periods have the same name month?

The answer is a little more complex. You should really think of a Period as a month. You can give several different periods (months) the same name, but they will appear as separate months on the calendar. And you wont be able to start the numbering differently, each period will start at day 1.

Keeping it simple, if you have months that are always 28 days, and you have 12 months per year. You would define each period, with a holidays section containing 2 holidays, one on the 1st, and one on the 15th. As long as its kept simple like that, its super easy.

But lets take a more difficult example using real world gregorian calendar. If a holiday occurs every 14 days, starting on Jan 1. The dates would be:
Jan 1
Jan 15
Jan 29
Feb 12
Feb 26
Mar 12
Mar 26
Apr 9
etc.

So you can see that the numbers dont align nicely. In order to implement this in FG, you would have to manually calculate every holiday through the year. If your calendar is simple in that it has an exact multiple of 14 days in the year, then they will always be spaced nicely. But if you have some odd number of days, like 365. Then if the holiday falls on Dec 28, FG will mark the next holiday on Jan 1. There isnt a way to use a function to alter the holidays.

yeknom
March 8th, 2020, 01:47
Thanks for this. I will see what I can do.

devinlc
April 25th, 2020, 21:13
I modified your tutorial calendar #1 to add in some new months and then used 7zip to pack the db and definition xml files into a .mod file. Put it into the mod folder for FG and when I went to the calendar window...nothing new appeared. Thinking I must have done something wrong, I directly transferred your .mod file for tutorial calendar #1 to the module folder, restarted FG, went to the calendar window, and still no new calendar.

Any advice or suggestions?

LordEntrails
April 25th, 2020, 21:24
I modified your tutorial calendar #1 to add in some new months and then used 7zip to pack the db and definition xml files into a .mod file. Put it into the mod folder for FG and when I went to the calendar window...nothing new appeared. Thinking I must have done something wrong, I directly transferred your .mod file for tutorial calendar #1 to the module folder, restarted FG, went to the calendar window, and still no new calendar.

Any advice or suggestions?
Don't zip the folder, only zip the contents. Make sure you are only using zip compression.

devinlc
April 25th, 2020, 21:30
Thanks. That helped! Apparently, 7zip defaults to archiving as a proprietary format rather than zip. Changing it to .zip format worked.

Regards,

Devin

mattekure
April 25th, 2020, 22:21
I modified your tutorial calendar #1 to add in some new months and then used 7zip to pack the db and definition xml files into a .mod file. Put it into the mod folder for FG and when I went to the calendar window...nothing new appeared. Thinking I must have done something wrong, I directly transferred your .mod file for tutorial calendar #1 to the module folder, restarted FG, went to the calendar window, and still no new calendar.

Any advice or suggestions?

can you post your mod here? the most common error is when zipping it up, you need to make sure you are not zipping up the folder itself, just the contents.

* EDIT: LOL, too slow. someone already got to it. Thanks

devinlc
April 25th, 2020, 22:23
No worries. And thanks a bunch for your great tutorial!

mattekure
April 26th, 2020, 02:39
Nothing wrong with 7zip. I use it exclusively. Just gotta be sure to select the zip format and not the 7z format.

Qaos
April 28th, 2020, 23:16
Hi, New here. I just downloaded FGU and am starting a Tal'Dorei campaign. I was hoping to find a calendar that was already made, but I have not. So with the instructions here, I believe I have created one. Please feel free to use it and if there are any suggestions or comments, please let me know.

Thanks
(Note, this calendar was based from the information in either "Tal'Dorei campaign settings" or "Explorer's Guide to Wildemount" both created/authored by Matt Mercer. So all the data is from him and gets all the credit for its origination - hope that covers any Copyright stuff needed).

Boldtaar
April 30th, 2020, 00:20
Created a new calendar from one of the examples and then zip files using windows 10 compressor and renamed .mod
Copied it to modules folder but none of calendar or module does not show up.

Using FGU and Morecore
Restarted program


Any suggestion what's wrong?

Qaos
April 30th, 2020, 00:46
So I downloaded my calendar into FGU. However, I noticed that all the months start on the first day (Mon). They don't continue through the week from the previous month. Can anyone help me figure out why that is?

EG: Jan has 29 days and the 29th is on Wed. Feb 1 starts on Mon (1st day of the week) instead of Thur (the next day after Jan 29th)

Qaos
April 30th, 2020, 00:58
So I downloaded my calendar into FGU. However, I noticed that all the months start on the first day (Mon). They don't continue through the week from the previous month. Can anyone help me figure out why that is?

EG: Jan has 29 days and the 29th is on Wed. Feb 1 starts on Mon (1st day of the week) instead of Thur (the next day after Jan 29th)

mattekure
April 30th, 2020, 00:59
Created a new calendar from one of the examples and then zip files using windows 10 compressor and renamed .mod
Copied it to modules folder but none of calendar or module does not show up.

Using FGU and Morecore
Restarted program


Any suggestion what's wrong?

You just have too many things lumped together wrong. you have an Asharisk.ext file and Asharisk.mod file both inside of a CalenderAsharisk.mod file. They should not be inside another mod file, but instead, the individual files should be copied to the directories. the Asharisk.mod file should be copied to the modules folder, and the Asharisk.ext file should be copied to your extensions folder.

mattekure
April 30th, 2020, 01:04
So I downloaded my calendar into FGU. However, I noticed that all the months start on the first day (Mon). They don't continue through the week from the previous month. Can anyone help me figure out why that is?

EG: Jan has 29 days and the 29th is on Wed. Feb 1 starts on Mon (1st day of the week) instead of Thur (the next day after Jan 29th)

The way to make the days roll over from month to month correctly requires an extension. I added one to the first post which is generic and should work for any calendar that doesnt have leap years. You just add the lunar day handler code in the calendar modules db.xml file, and you make sure to enable the extension.

Qaos
April 30th, 2020, 02:16
So I downloaded my calendar into FGU. However, I noticed that all the months start on the first day (Mon). They don't continue through the week from the previous month. Can anyone help me figure out why that is?

EG: Jan has 29 days and the 29th is on Wed. Feb 1 starts on Mon (1st day of the week) instead of Thur (the next day after Jan 29th)

Figured it out. needed this line in the db.xml file:
<lunardaycalc type="string">TalDorei</lunardaycalc>

Still have an issue with the .lua file (working on fixing it)

Andraax
May 1st, 2020, 00:11
Hi, New here. I just downloaded FGU and am starting a Tal'Dorei campaign. I was hoping to find a calendar that was already made, but I have not.

I made one a couple years ago, right here: Help with making a custom Calendar ext for Critical Role "Tal-dorei campaign guide" (https://www.fantasygrounds.com/forums/showthread.php?39435-Help-with-making-a-custom-Calendar-ext-for-Critical-Role-quot-Tal-dorei-campaign-guide-quot&p=348317&viewfull=1#post348317)

arikjtc
May 6th, 2020, 10:47
Hi, I am about as plebian as they come with coding. I am also a visual learner. is there any way you could do a video tutorial of this for the complete layman? I understand completely if you don't have the time/inclination. Appreciate your efforts regardless!

Broadcast Bard
May 7th, 2020, 02:30
Yeah, I read through this stuff and my brain starts to turn to mush, even though I know how to do HTML and some other coding, so the ideas are familiar.

https://www.drivethrurpg.com/product/59845/Harn-Religious-Calendar (It's free and the setting is EXCELLENT)

I have 12 months, each has 6, 5 day weeks.

On the second day of all weeks there is a high mass for one religion, but there are a smattering of other holidays all over the place.

Is there an easy way to approach these holiday placements?

(Mostly I just wish there was an existing Harn Calandar out there. lol)

mattekure
May 7th, 2020, 13:32
Yeah, I read through this stuff and my brain starts to turn to mush, even though I know how to do HTML and some other coding, so the ideas are familiar.

https://www.drivethrurpg.com/product/59845/Harn-Religious-Calendar (It's free and the setting is EXCELLENT)

I have 12 months, each has 6, 5 day weeks.

On the second day of all weeks there is a high mass for one religion, but there are a smattering of other holidays all over the place.

Is there an easy way to approach these holiday placements?

(Mostly I just wish there was an existing Harn Calandar out there. lol)

Try this one

aGeekNamedShane
May 7th, 2020, 14:44
Sorry for the post necromancy. Still using Classic Fantasy Grounds (Steam not selling the upgrade yet) and I'm trying to include the calendar directly in a campaign setting mod I'm making. Is there a way to do this, or do I need to include it directly in a module? Is that possible, or do I need to include both if I distribute the module for other GMs?

mattekure
May 7th, 2020, 14:47
Sorry for the post necromancy. Still using Classic Fantasy Grounds (Steam not selling the upgrade yet) and I'm trying to include the calendar directly in a campaign setting mod I'm making. Is there a way to do this, or do I need to include it directly in a module? Is that possible, or do I need to include both if I distribute the module for other GMs?

Its possible. But you cant create the calendar from within FG. so to include it you would need to create your module. extract it and define the calendar within the db.xml, then rezip it up into a module. Most though will keep it as a separate module so it can be updated and shared. its also helpful to have it separate since you would need to go back and re-add the calendar stuff after every module export if it were part of the campaign setting module.

Highlad
June 5th, 2020, 09:41
Great tutorial, cheers mate. Got everything working except for one thing. While the calendar displays the dates and days correctly, the day name displayed at the top of the window, and the day name when pushed to chat, show the wrong day. I think it seems to be stretching the week over the entire year, as all the days in each couple months give the same name, but as you progress to later months, it shows later days in the week... Very strange.
Example: https://puu.sh/FSTIb/8040e21c3a.jpg

mattekure
June 5th, 2020, 12:36
Great tutorial, cheers mate. Got everything working except for one thing. While the calendar displays the dates and days correctly, the day name displayed at the top of the window, and the day name when pushed to chat, show the wrong day. I think it seems to be stretching the week over the entire year, as all the days in each couple months give the same name, but as you progress to later months, it shows later days in the week... Very strange.
Example: https://puu.sh/FSTIb/8040e21c3a.jpg

Can you post the calendar you are seeing this with? I dont see that in any of my tests. Also, do you have any other extensions running?

Highlad
June 6th, 2020, 09:09
Can you post the calendar you are seeing this with? I dont see that in any of my tests. Also, do you have any other extensions running?

No other extensions, aside from the 5e wizards theme. I'm using your 'Calendar - Generic Lunar Day' extension. I've attached the .mod file for you to have a look at.

mattekure
June 6th, 2020, 14:56
No other extensions, aside from the 5e wizards theme. I'm using your 'Calendar - Generic Lunar Day' extension. I've attached the .mod file for you to have a look at.

Ok, I can replicate this. I'll take a look and see whats going on, it appears to be a bug in the generic lunar day handler ext.

mattekure
June 6th, 2020, 15:29
No other extensions, aside from the 5e wizards theme. I'm using your 'Calendar - Generic Lunar Day' extension. I've attached the .mod file for you to have a look at.

Thanks for pointing this out. I believe I have fixed it. The updated lunar day handler ext is attached to the first post. should be v1.1

Highlad
June 7th, 2020, 11:33
Thanks for pointing this out. I believe I have fixed it. The updated lunar day handler ext is attached to the first post. should be v1.1

Perfect mate, I'll give it a try today. Thanks for the help!

Highlad
June 7th, 2020, 22:25
Thanks for pointing this out. I believe I have fixed it. The updated lunar day handler ext is attached to the first post. should be v1.1

It works perfectly now mate! Well done and thanks again. :)

GunbunnyFuFu
June 10th, 2020, 22:16
Good day! Trying my hand at a calendar for the Midgard Campaign Setting from Kobold Press....I've got the generic lunar day handler ext loaded (and loaded) but the days still don't wrap...every month starts off on the same day of the week (Moonday). I'm wondering if it's because Midgard has a few "Intercalendar" holidays in which they're one day long...for example, there is New Year's Dawn, which is a one day holiday that happens before the month of Springmelt...

GBFF

mattekure
June 10th, 2020, 22:44
Good day! Trying my hand at a calendar for the Midgard Campaign Setting from Kobold Press....I've got the generic lunar day handler ext loaded (and loaded) but the days still don't wrap...every month starts off on the same day of the week (Moonday). I'm wondering if it's because Midgard has a few "Intercalendar" holidays in which they're one day long...for example, there is New Year's Dawn, which is a one day holiday that happens before the month of Springmelt...

GBFF

If you have the ext loaded and its still not wrapping, double check your calendars db.xml file and make sure it has this line defined for your calendar.

<lunardaycalc type="string">LunarWrap</lunardaycalc>

There should only be one <lunardaycalc> tag in a calendar. If you still have trouble, post your calendar here and I can take a look

GunbunnyFuFu
June 11th, 2020, 00:19
Yep..single tag in there for that. I *think* I've attached the DB.XML.

GBFF

mattekure
June 11th, 2020, 00:30
Yep..single tag in there for that. I *think* I've attached the DB.XML.

GBFF

You have to remove this line

<periodvarcalc type="string"></periodvarcalc>

periodvarcalc is only used when you are doing leap years which 99% of fantasy calendars dont use. Remove that line, enable the extension and it works fine.

https://imgur.com/hMLlsOL.jpg

GunbunnyFuFu
June 11th, 2020, 00:43
Thank you!!!

scorpiodrush
September 7th, 2020, 20:35
Apologies, I'm not good at any of this modding stuff for FGC/FGU
I wanted to create a simple calendar with 8 35 day months. Each week is 7 days, so every month starts on the same day.
The part that throws a wrench is I'd like to track 3 Lunar moons and their phases separately and have the Full/New Moons displayed on Calendar dates. Has anyone done something like this with the Calendars in FGU?

Months
Thunsheer
Undilar
Brussendar
Sydenstar
Fessuran
Quen'pillar
Duscar
Malsuthar

Days of Week
Miressen
Grissen
Whelsen
Conthsen
Folsen
Yulisen
Da'Leysen

Lunar Objects - I only want to show the New/Full phases with the Calendar (gets too busy otherwise).
Vograit - 16 day cycle
Raazlun - 28 days cycle
Aslian - 42 days cycle

Is this possible?

mattekure
September 7th, 2020, 20:40
Apologies, I'm not good at any of this modding stuff for FGC/FGU
I wanted to create a simple calendar with 8 35 day months. Each week is 7 days, so every month starts on the same day.
The part that throws a wrench is I'd like to track 3 Lunar moons and their phases separately and have the Full/New Moons displayed on Calendar dates. Has anyone done something like this with the Calendars in FGU?

Months
Thunsheer
Undilar
Brussendar
Sydenstar
Fessuran
Quen'pillar
Duscar
Malsuthar

Days of Week
Miressen
Grissen
Whelsen
Conthsen
Folsen
Yulisen
Da'Leysen

Lunar Objects - I only want to show the New/Full phases with the Calendar (gets too busy otherwise).
Vograit - 16 day cycle
Raazlun - 28 days cycle
Aslian - 42 days cycle

Is this possible?

The calendar is pretty straightforward. You can do it manually following this tutorial, or you can use my new method of using Donjon's Calendar utility to create the calendar, then my donjon2fg website to convert into a FG module. (Note, this process will not track the moons, just the months/weeks/days)

Donjons calendar creator utility https://donjon.bin.sh/fantasy/calendar/

My donjon2fg website https://mattekure.com/donjon2fg/

For the moons, have you checked out https://www.fantasygrounds.com/forums/showthread.php?46672-Andraax-Moon-Tracker-Extension? Its designed to track multiple moons on the calendar.

scorpiodrush
September 7th, 2020, 22:04
@mattekure I saw it, but I wasn't sure if it was still functioning.

mattekure
September 7th, 2020, 22:05
The original author hasnt updated it in awhile, but several others have posted little fixes toward the end of the thread.

scorpiodrush
September 7th, 2020, 23:44
The calendar is pretty straightforward. You can do it manually following this tutorial, or you can use my new method of using Donjon's Calendar utility to create the calendar, then my donjon2fg website to convert into a FG module. (Note, this process will not track the moons, just the months/weeks/days)

Donjons calendar creator utility https://donjon.bin.sh/fantasy/calendar/

My donjon2fg website https://mattekure.com/donjon2fg/

For the moons, have you checked out https://www.fantasygrounds.com/forums/showthread.php?46672-Andraax-Moon-Tracker-Extension? Its designed to track multiple moons on the calendar.



When I loaded the Module an tried to advance the year past 0, It seems to break if I change the Year I've tried this with and without the Lunar Day Handler. and not usi9ng the moon tracker.

The months get reduced and then seem to stop altogether.
https://cdn.discordapp.com/attachments/365274016237486101/752661954472181870/unknown.png

mattekure
September 8th, 2020, 00:06
In your screenshot it shows you editing the Era, not the Year. The Era field doesnt really do anything in FG. Its like we use AD, or BC, or BCE in our years.

As for the bug you noticed, I believe thats specific to Unity. Are you using Unity? If so, please report it on that forum as I have never seen this in Classic

scorpiodrush
September 8th, 2020, 00:35
Yes Mattekure, This is in Unity.

I had hit enter so the active cursor went to era, but It was the Year I was changing. I'll go to the unity forum.

ChipDancer
September 23rd, 2020, 06:54
Hello, hoping there are a few people that can assist me with a few issues I am having with my custom calendar.
39591

First, I have this empty space between the dates and the days of the week in each month highlighted in green. Any help would be appreciated please!
Second, How can I set my starting day for the year so that the dates flow matching the existing calendar that I have been using for the last few years please?
Lastly, how can I change the way the date is shown in the top of the calendar and especially on how it is reported when you click 'Outdate Date to Chat' button please.

I've poured through a lot of examples and have not seen any code in the db.xml or *.lua fiies I have examined that would give me an example to work from so any help would be greatly appreciated please!

(^_^)

ChipDancer

Alyksandrei
October 5th, 2020, 09:41
I'm also looking for a way to start my calendar in the middle of the "week"...and to wrap each year (like our real-world calendar) such that if the last day of one year is on Eighth-day, the first day of the next year is on Ninth-day. Is there a way to handle this in FG, or do I need to start each year on the first day of the week, and calculate the number of days in a year to end the year on the last day of the week?

mattekure
October 5th, 2020, 18:00
I'm also looking for a way to start my calendar in the middle of the "week"...and to wrap each year (like our real-world calendar) such that if the last day of one year is on Eighth-day, the first day of the next year is on Ninth-day. Is there a way to handle this in FG, or do I need to start each year on the first day of the week, and calculate the number of days in a year to end the year on the last day of the week?

Without an extension, all calendars will default to starting the first day of the year on the first day of the week, and the first day of each month on the first day of the week.

There are two functions detailed in the tutorial that allow you to change that default behavior. You register them as a LunarDayHandler and a MonthVarHandler.

A LunarDayHandler function is given a date (Year, Month, day) and needs to return a number representing the day of the week. So the first day of the week could be 1, second day would be 2, etc. This is the function that needs to be defined in order to get days to flow properly so that a month ending on the 3rd day of the week will be followed by a month starting on the 4th day of the week. Since all calendars start at the first day of the week, once you have the default code working for month to month rollover, you can shift the week simply by adding to the returned value.

The other function is the MonthVarHandler, which is given a date (Year and Month only), and returns a number of days difference from a standard month. This is how you implement leap years if your calendar has them. For example, in the gregorian calendar for the month of February, there would be some math that returns a 0 most of the time, but every 4 years returns a 1, representing 1 additional day added to the month of Feb.

ChipDancer
October 5th, 2020, 18:59
I'm also looking for a way to start my calendar in the middle of the "week"...and to wrap each year (like our real-world calendar) such that if the last day of one year is on Eighth-day, the first day of the next year is on Ninth-day. Is there a way to handle this in FG, or do I need to start each year on the first day of the week, and calculate the number of days in a year to end the year on the last day of the week?

Hopefully this will help you as it took me some time to reverse engineer the code using various examples to finally achieve what I wanted! :)

This is the code for my calendar.lua file.
You will need to make sure that any variable declarations match what is in your db.xml and extension.xml files! :)


-- This function sets up our custom calendar calling functions.
--

function onInit()
-- Register the function to calculate the day of week for the Twilight calendar. In the calender mod db.xml, you tell FG which function to use with the <lunardaycalc type="string">Twilight</lunardaycalc> tag.
CalendarManager.registerLunarDayHandler("Twilight", calcTwilightLunarDay);
-- Register the function to calculate additional days for a month in a leap year for the Twilight calendar. In the calender mod db.xml, you tell FG which function to use with the <periodvarcalc type="string">Twilight</periodvarcalc> tag
-- CalendarManager.registerMonthVarHandler("Twilight", calcTwilightMonthVar);
end

-- This function is the default Gregorian day of week calculation defined in CoreRPG. It calculates the day of the week based on the year, month and day. For a full explanation of the math involved, see https://cs.uwaterloo.ca/~alopez-o/math-faq/node73.html


function calcTwilightLunarDay(nYear, nMonth, nDay)
local rYear = nYear * 362; --total days in the calendar year
local arrayMonthDays = {0,28,58,89,120,150,178,209,239,269,300,331,362}; --months broken into days starting with month 0
if (nMonth == 0)
then
nMonth = 1; --sets current month?
end
local rMonthDays = arrayMonthDays[nMonth];
local rDay = (rYear + rMonthDays + nDay)%7; --not sure what this does yet?
return (rDay+6); --sets start day of the year
end

ChipDancer
October 5th, 2020, 19:01
Mattekure,

Do you know or have a tutorial on how to modify the format of the date that is provided when you click the button on the calendar that sends the date to the chat box by any chance?

Thanks in advance!

mattekure
October 5th, 2020, 19:26
Mattekure,

Do you know or have a tutorial on how to modify the format of the date that is provided when you click the button on the calendar that sends the date to the chat box by any chance?

Thanks in advance!

I dont have a specific tutorial on it. There are 2 other handlers you can register to control how dates are displayed when output to chat (CalendarManager.registerDayDisplayHandler and CalendarManager.registerDateDisplayHandler). Here is an example from the traveller calendar.



function onInit()
CalendarManager.registerDayDisplayHandler("xtraveller_imperial", TravdisplayImperialDay);
CalendarManager.registerDateDisplayHandler("xtraveller_imperial", TravdisplayImperialDate)
end

function TravdisplayImperialDay(nDay)
return string.format("%03d", nDay);
end
function TravdisplayImperialDate(sEpoch, nYear, nMonth, nDay, bAddWeekDay, bShortOutput)
local sDay = TravdisplayImperialDay(nDay);

local sOutput;
if bShortOutput or (nYear == 0) then
sOutput = sDay;
else
sOutput = string.format("%05d", nYear) .. "-" .. sDay;
end
return sOutput
end

ChipDancer
October 7th, 2020, 05:02
Thanks Mattekure!

I was able to mostly get what I wanted, well damned near everything with your example and thought to share what I did to get my results!

Here is my date to chat results:

The date is the 12nd day of Falon'Din (Hollows Breath), Year 382, Era of Twilight

The problem I am seeing is in the day suffix: day 11 is always the 11st, and day 13 is always the 13rd instead of 13th. No clue where to address this at! LOL!
-any help would be great, but it's a little thing compared to everything else! :)

Here is the code function so people can see the changes I made for my date to chat results:
The file is manager_calendar.lua


function getDateString(sEpoch, nYear, nMonth, nDay, bAddWeekDay, bShortOutput)
local sDateFormat = DB.getValue("calendar.data.dateformat");
if sDateFormat and aDateDisplay[sDateFormat] then
return aDateDisplay[sDateFormat](sEpoch, nYear, nMonth, nDay, bAddWeekDay, bShortOutput);
end

local sMonth = getMonthName(nMonth);
local sSuffix = Interface.getString("message_calendardaysuffix" .. (nDay % 10));
local sDay = tostring(nDay) .. (sSuffix or "");

local sOutput;
if bShortOutput or (nYear == 0) then
sOutput = sDay .. " " .. sMonth;
else
sOutput = "the " .. sDay .. " day of " .. sMonth .. ", Year " .. nYear .. ", Era of " .. sEpoch;
end
-- if bAddWeekDay then
-- local nWeekDay = getLunarDay(nYear, nMonth, nDay);
-- local sWeekDay = getLunarDayName(nWeekDay);
-- sOutput = sWeekDay .. ", " .. sOutput;
-- end
return sOutput;

fabiocm
October 8th, 2020, 21:11
Hello. Is there a way to insert information for the players or for the GM in the module? Where?

ChipDancer
October 8th, 2020, 22:00
Hello. Is there a way to insert information for the players or for the GM in the module? Where?

Uhm...You are going to need to be a lot more specific with your question! LOL!!!

What information are you trying to insert and where and from are you trying to insert it?

:)

LordEntrails
October 8th, 2020, 22:15
Hello. Is there a way to insert information for the players or for the GM in the module? Where?
If you double click on a date, a window will open. You can enter GM only or Player info there.

damned
October 8th, 2020, 22:35
Also Player Agency will allow players to record info into any date the GM has initiated.

fabiocm
October 9th, 2020, 01:55
Uhm...You are going to need to be a lot more specific with your question! LOL!!!

What information are you trying to insert and where and from are you trying to insert it?

:)

Yeah, I'm seeing :p
Let's see if my english can be a little better now.

What I meant is: how to create a calendar module with some log entries whitin it? For example, I don't want only the holiday name, I want the full description of this holiday in the log.

40060

I want to add information in the red rectangle direct from the module.

ChipDancer
October 9th, 2020, 02:07
I am not sure if you can tag calendar info in a module precisely, maybe, I have had no need to test that, but you can always post the information into the calendar date directly in the players txt box to simulate the same thing or and perhaps easier, create the information in the module story element as a text formatted paragraph (s) and just share using the text to chat button from the story element. Hope that helps.

Fiacha
October 10th, 2020, 04:52
So I downloaded my calendar into FGU. However, I noticed that all the months start on the first day (Mon). They don't continue through the week from the previous month. Can anyone help me figure out why that is?

EG: Jan has 29 days and the 29th is on Wed. Feb 1 starts on Mon (1st day of the week) instead of Thur (the next day after Jan 29th)

Do you still have the "broken" version of this calendar? This behavior is what I need to implement mine. I have two 1 day special events that are not actual weekdays.

Fiacha
October 10th, 2020, 05:45
Solved. Exploited leaving an empty periodvarcalc string in the definition file. Not a perfect rendering, but it produces the right number of days and keeps the weeks aligned with the start of the month and doesn't require any additional code to work.

Renfrost
October 11th, 2020, 00:58
Is this still relevant for unity? I'm having trouble finding the path I need to dump my xml files into (I'm working off windows and there seem to be dirs for fgu all over).

mattekure
October 11th, 2020, 01:12
Is this still relevant for unity? I'm having trouble finding the path I need to dump my xml files into (I'm working off windows and there seem to be dirs for fgu all over).

Yes, nothing related to creating custom calendars has changed between Classic and Unity. The easy way to get to the right path for Unity files is to use the folder icon on the launcher to open the FG data folder. Then Extensions go into the extensions folder, and modules go into the modules folder.

https://imgur.com/p8YkdbD.jpg

https://imgur.com/bKOEFUg.jpg

mattekure
October 11th, 2020, 01:16
Also, remember that the xml files will become part of the calendar module, which needs to be zipped up and the file extension renamed to .mod. That will be copied to the modules directory. Calendar Extensions (not always needed, but sometimes) would be copied into the extensions folder so it can be loaded. Most fantasy calendars would only ever need the generic lunar day handler extension included in the first post.

Kreger Bjorn
November 24th, 2020, 17:39
I'm hoping you can help me with a calendar related question. I'm using the default Golarion calendar that comes with Fantasy Grounds for my PFRPG2 game. The current year on the Golarion calendar is 4720 but mirrors 2020 of the Gregorian calendar. However the 1st day of the year 4720 is an Oathday (Thursday) but should be Wealday (Wednesday). So the whole year is one day off for me. I know that the Golarion and Gregorian calendars are the same except for names of the week and holidays. in the following thread here (https://www.fantasygrounds.com/forums/showthread.php?63899-In-game-calendar-issues) Moon Wizard was able to provide me with an answer, but I'm afraid I don't understand it or how to proceed. After reviewing the info you provided I think I need to do something with your Generic Lunar Day Handler but am a bit lost. With 4720 (2020) being a leap year cause problems too? Any light you can shed on this issue would be greatly appreciated.

mattekure
November 24th, 2020, 17:51
I'm hoping you can help me with a calendar related question. I'm using the default Golarion calendar that comes with Fantasy Grounds for my PFRPG2 game. The current year on the Golarion calendar is 4720 but mirrors 2020 of the Gregorian calendar. However the 1st day of the year 4720 is an Oathday (Thursday) but should be Wealday (Wednesday). So the whole year is one day off for me. I know that the Golarion and Gregorian calendars are the same except for names of the week and holidays. in the following thread here (https://www.fantasygrounds.com/forums/showthread.php?63899-In-game-calendar-issues) Moon Wizard was able to provide me with an answer, but I'm afraid I don't understand it or how to proceed. After reviewing the info you provided I think I need to do something with your Generic Lunar Day Handler but am a bit lost. With 4720 (2020) being a leap year cause problems too? Any light you can shed on this issue would be greatly appreciated.

The main issue as I see it is that while on the surface, the Golarion and the Gregorian calendar seem to align, there is one big difference. Leap years. The gregorian calendar has a very complicated system of leap years, every 4 years except when its divisible by 100 unless if its divisible by 400. This means that my generic lunar day handler wont work because the system does have leap years.

The Golarian calendar has leap years only every 8 years. So the calculations for the days and weeks really need a modified version of the gregorian calendar system that takes the 8 year cycle into account rather than the gregorian leap year system.

I'll take a look to see what changes need to be made. It doesnt sound particularly difficult.

Moon Wizard
November 24th, 2020, 18:01
@mattekure,

If you come up with the lunarmonth and lunarday calc functions, and you don't mind me incorporating into CoreRPG; I can add them into the base code. I just in the middle of fixes and trying to put together a release; so didn't have time to work out all the details specific to Golarion.

Regards,
JPG

mattekure
November 24th, 2020, 18:04
@mattekure,

If you come up with the lunarmonth and lunarday calc functions, and you don't mind me incorporating into CoreRPG; I can add them into the base code. I just in the middle of fixes and trying to put together a release; so didn't have time to work out all the details specific to Golarion.

Regards,
JPG

no problem. I'll post the functions here once done. If you are touching the calendar code in CoreRPG, you might also consider adding the generic lunar day handler function which will do the days of the week rollover for any normal calendar that doesnt have leap years.

Kreger Bjorn
November 24th, 2020, 18:07
Thank you both for all the help!

mattekure
November 24th, 2020, 19:00
The following functions seem to work and align the Golarian calendar with the ones I found online. I've attached the mod/ext I used for testing. This was the online calendar I compared against. https://dungeonetics.com/calendar/



function calcGolarionLunarDay(nYear, nMonth, nDay)
local nZellerYear = nYear;
local nZellerMonth = nMonth;
if nMonth < then
nZellerYear = nZellerYear - 1;
nZellerMonth = nZellerMonth + 12;
end
local nZellerDay = (nDay + math.floor(2.6*(nZellerMonth + 1)) + nZellerYear + math.floor(nZellerYear / 8) -1) % 7;
if nZellerDay == 0 then
return 7;
end
return nZellerDay;
end

function calcGolarionMonthVar(nYear, nMonth)
if nMonth == 2 then
local nYear = DB.getValue("calendar.current.year", 0);
if (nYear % 8) == 0 then
return 1;
end
end
return 0;
end

Moon Wizard
November 24th, 2020, 20:30
Ok, I've pushed the changes in the CoreRPG ruleset; and the included calendar module. You'll have to reset the calendar; and add it back from the calendar module again.

Regards,
JPG

Sulimo
December 13th, 2020, 06:09
I have a couple of questions.

I mostly have a calendar mod done. I managed to get 4 of the 5 calendars the way I want them.

I used the generator/converter that was linked a few pages back.

I am trying to create the Shire Calendar (https://www.glyphweb.com/arda/s/shirecalendar.html) from the Lord of the Rings.

Every year always starts of Saturday, and ends on Friday.

There are 4 holidays, 1 Yule (the last day of the year), 2 Yule (the first day of the year), 1 Lithe (day before Midyear's Day), 2 Lithe (day after Midyear's Day).

There are up to two days in the middle of the year. The first is Midyear's Day, the second is called Overlithe and only occurs on Leap Years.

I have the calendar setup except for being able to setup Midyear's Day and Overlithe (for Leap Years) to not appear as actual days of the week.

So for example, 1 Lithe would be on Friday, and 2 Lithe would be on Saturday. Midyear's day would fall in between the two Lithe days, but is not is not assigned to a day of the week. Overlithe is the same for leap years.

Can this be done?



Another issue I am having is that it is not setting days properly. Months always start on the same day instead (Saturday) of progressing like expected, so for example 1 Yule is on a Saturday, Afteryule 1 is a Sunday (or should be). If I set it as Gregorian, it oddly skips a day between each the end of each period/month and the next, basically going from Saturday to Monday in the example of 1 Yule and Afteryule.

I'm not sure how to address this issue.

Jiminimonka
February 18th, 2021, 19:35
Is it possible to have Year cycles (like the chinese year cycle, year of the dragon, etc.) in a custom calendar?

Also is it possible to have the calendar not show the numbers for the days of the month and to show more than 2 letters for the weekdays?

Jiminimonka
February 18th, 2021, 21:46
I have a couple of questions.

I mostly have a calendar mod done. I managed to get 4 of the 5 calendars the way I want them.

I used the generator/converter that was linked a few pages back.

I am trying to create the Shire Calendar (https://www.glyphweb.com/arda/s/shirecalendar.html) from the Lord of the Rings.

Every year always starts of Saturday, and ends on Friday.

There are 4 holidays, 1 Yule (the last day of the year), 2 Yule (the first day of the year), 1 Lithe (day before Midyear's Day), 2 Lithe (day after Midyear's Day).

There are up to two days in the middle of the year. The first is Midyear's Day, the second is called Overlithe and only occurs on Leap Years.

I have the calendar setup except for being able to setup Midyear's Day and Overlithe (for Leap Years) to not appear as actual days of the week.

So for example, 1 Lithe would be on Friday, and 2 Lithe would be on Saturday. Midyear's day would fall in between the two Lithe days, but is not is not assigned to a day of the week. Overlithe is the same for leap years.

Can this be done?



Another issue I am having is that it is not setting days properly. Months always start on the same day instead (Saturday) of progressing like expected, so for example 1 Yule is on a Saturday, Afteryule 1 is a Sunday (or should be). If I set it as Gregorian, it oddly skips a day between each the end of each period/month and the next, basically going from Saturday to Monday in the example of 1 Yule and Afteryule.

I'm not sure how to address this issue.

Have you checked out the Flanaess Calendar (World of Grayhawk)? That as a calendar with intercalary days etc. MIght be able to check out the .xml files and see how its done there.

The Wayward Wizard
April 11th, 2021, 07:09
Hey! Thanks for this! I just tweaked your example calendar into one for my world. Thank you for the excellent guide.

PilgrimJavi
April 16th, 2021, 23:59
Same result here devinlc.

Any help Mattekure?

damned
April 17th, 2021, 00:32
Welcome PilgrimJavi

If you are zipping up an extension - dont zip up the parent folder and make sure you just use vanilla zip compression, no fancy options and no rar/arj/7z etc.

PilgrimJavi
April 20th, 2021, 00:53
Thanks. I'll give it a go.

DerSavage
May 16th, 2021, 15:03
Still new to Fantasy Grounds Unity. I try to figure out how make Harn RPG style calendar for it.

There are 12 months, 30 days each month and 10-day week (no weekday names). And no leap years. I'm looking to add religious holidays and other stuff to it. Have anyone made Harn calendar already or should I make my own - and how to make it.

Here is link to one outside page with more info (not mine page): https://harnmaster.obsidianportal.com/wikis/calendar

mattekure
May 16th, 2021, 15:31
Still new to Fantasy Grounds Unity. I try to figure out how make Harn RPG style calendar for it.

There are 12 months, 30 days each month and 10-day week (no weekday names). And no leap years. I'm looking to add religious holidays and other stuff to it. Have anyone made Harn calendar already or should I make my own - and how to make it.

Here is link to one outside page with more info (not mine page): https://harnmaster.obsidianportal.com/wikis/calendar

There was a harn calendar posted earlier in this thread. https://fantasygrounds.com/forums/showthread.php?47885-Fantasy-Grounds-Custom-Calendar-Tutorial&p=506302&viewfull=1#post506302

DerSavage
May 16th, 2021, 20:39
There was a harn calendar posted earlier in this thread. https://fantasygrounds.com/forums/showthread.php?47885-Fantasy-Grounds-Custom-Calendar-Tutorial&p=506302&viewfull=1#post506302

Oh, must have missed that post. This is awesome, saved me a lot of time. Thank you for your fast response.

DerSavage

Tabarkus
July 14th, 2021, 19:28
Anyone have a better understanding of the calendar setup than I? I've made a Nehwon/Lankhmar calendar. See below. Is there any way to change the calendar output format to accommodate for the fact that there are 30 differently named days in a month, so that they are not arranged in rows of 30 but by 10 or something? Also can the chatbox output be changed? Currently it reads: "The date is [day], [date] [month]..."; so on my calendar it reads: "The date is Bat, 1st Panther, 429 Year of the Snake". I'd like to make that different but couldn't figure out how to change that.

Jiminimonka
July 14th, 2021, 19:47
Anyone have a better understanding of the calendar setup than I? I've made a Nehwon/Lankhmar calendar. See below. Is there any way to change the calendar output format to accommodate for the fact that there are 30 differently named days in a month, so that they are not arranged in rows of 30 but by 10 or something? Also can the chatbox output be changed? Currently it reads: "The date is [day], [date] [month]..."; so on my calendar it reads: "The date is Bat, 1st Panther, 429 Year of the Snake". I'd like to make that different but couldn't figure out how to change that.

I asked this very same question many months back. Apparently not possible without a complete rewrite of the Calendar system. I suspect if they add JSON to FGU it might be easier to implement completely different calendars.

Tabarkus
July 14th, 2021, 20:11
Thanks for the quick answer Jim.

Moon Wizard
July 14th, 2021, 20:25
The data format has nothing to do with support for thirty differently named days. It's the fact that the entire calendar window UI would have to be redesigned to somehow not show the entire lunar week cycle; or find a way to display the lunar week day abbreviations in a different way.

Regards,
JPG

saintsfan2021
July 15th, 2021, 07:52
I'm not entirely sure how to convert a .zip file to a .mod file. I've made the custom calendar, put the description XML and db XML files into a .zip, and now have been slamming my head against the wall for 45 minutes because of the .mod conversion.

Moon Wizard
July 15th, 2021, 08:06
A Fantasy Grounds .mod file is just a .zip file with the file extension changed from .zip to .mod. Just rename Yu'Foren.zip to Yu'Foren.mod. Also, make sure that file extensions are not being hidden in your file explorer settings, so you can see the file extensions.

Regards,
JPG

LordEntrails
July 15th, 2021, 15:13
As well, when you zip your contents, do not zip the folder, only the contents of the folder.

slitherrr
July 19th, 2021, 19:21
I have a display problem, which I outline here: https://www.fantasygrounds.com/forums/showthread.php?69710-Calendar-days-do-not-split-on-week-lengths-leading-to-awful-display&p=611771#post611771. In a nutshell, the lunar week display is correct the first time the module is ever loaded, but on every subsequent load of the campaign it breaks the display on every second day rather than on the lunar week. I can't figure out why. This is in Unity. .mod and .ext and screenshots are in that thread.

slitherrr
July 20th, 2021, 20:11
Follow-up from that thread for this one: Resetting the calendar was helpful and seems to have resolved the glitch.

ChipDancer
August 17th, 2021, 21:04
Mattekure,

Been a while since I've messed with my calendar, but after creating a new campaign to baseline issues I noticed something small bothering the heck out of me and can't figure out which *lua file to edit the line in the following highlighted portion of this pic:

48735

It is not part of the manager.calendar.lua and I have no clue where it might be! LOL!

I'd also love to know how to edit the frames so that the names populate without truncation as in this high lighted example from the calendar:

48736

Also, any ideas for displaying holidays in the 'Output Date to Chat' function?

So if anyone has any ideas please let me know where to find these assets at and thanks in advance! :)

ChipDancer

mattekure
August 17th, 2021, 21:45
Mattekure,

Been a while since I've messed with my calendar, but after creating a new campaign to baseline issues I noticed something small bothering the heck out of me and can't figure out which *lua file to edit the line in the following highlighted portion of this pic:

48735

It is not part of the manager.calendar.lua and I have no clue where it might be! LOL!

I'd also love to know how to edit the frames so that the names populate without truncation as in this high lighted example from the calendar:

48736

Also, any ideas for displaying holidays in the 'Output Date to Chat' function?

So if anyone has any ideas please let me know where to find these assets at and thanks in advance! :)

ChipDancer

The line "The date is" is not defined in one of the lua files. It is defined in the CoreRPG\strings\strings_common.xml. This value is concatenated to whatever the getCurrentDateString() function returns and output to chat.



<string name="message_calendartime">The time is</string>
<string name="message_calendardate">The date is</string>


The Era field width is defined as part of the windowclass "calendar_main" which is defined in the CoreRPG\utility\utility_calendar.xml file.



<basicstring name="currentepoch" source="current.epoch">
<anchored to="currentyear" position="righthigh" offset="10,0" width="30" height="20" />
<font>calendarbold</font>
<center />
</basicstring>
<label_fieldtop>
<anchored to="currentepoch" />
<static textres="calendar_label_epoch" />
</label_fieldtop>


Adding holidays to the output date to chat should be fairly straightforward. You can write your own output function and register it with your calendar type in onInit using aDateDisplay["calendartype"] = myDisplayFunc;

you can see examples of this in the manager_calander.lua onInit() function. Then when the outputDate() function is called, it calls getDateString with the specific date and passes all the info like year, month, etc into it. If there is a custom display function defined then it will pass that data on to it and return whatever it returns. Within your custom function, you can use isHoliday(nMonth, nDay) and getHolidayName(nMonth, nDay) to get any holiday that might be on that day to return it.

ChipDancer
August 18th, 2021, 16:05
Mattekure,

I did not expect anyone to actually know what I was talking about in so much detail; ARIGATO!

(^_^)

With your help I was successful in making the alterations to my game's calendar!

48750

48751

My next goal, besides figuring out how to add holidays to the chat message, is to figure out how to insert a carriage return to split the name of my months into two lines as the current length of the whole name is simply overrunning the space of the month frame as in this example:

48752

Any help from the community would be extremely grateful and I hope by the time I'm done all this information will be able to be posted in a single post so that others who are desiring a custom calendar will have something to follow! :)

Thanks in advance,

(^_^)

ChipDancer

mattekure
August 18th, 2021, 16:14
mattekure,

i did not expect anyone to actually know what i was talking about in so much detail; arigato!

(^_^)


どういたしまして

ChipDancer
August 18th, 2021, 16:52
私の日本は笑を吸う!

(^_^)

cwright45
September 29th, 2021, 20:30
Is there a way to export user and GM entries from a calendar in FGU? If so, is there a way to import those entries on the same date to an updated version of the original calendar.

Hurray, I solved it. The original entries were preserved when I switched the calendars in a test campaign. And, then successful when I <right click on calendar> and RESET the calendars by bringing in the NEW version of the original calendar. The new version had the same months and days in the month. I had just renamed two of the days of the week and edited the names of the holidays.

CallMeTheFalcon
October 25th, 2021, 01:30
Hello! I made a topic about this issue on the forum but I was recommended to post it here as well. When I'm outputting the date in my calendar, Fantasy Grounds is adding the wrong suffix to certain days of the month. Specifically, it is changing the 11th, 12th, and 13th to the 11st, 12nd, and 13rd respectively. What is causing this and is there any solution to fix it? I have attached a screenshot illustrating the error.

mattekure
October 25th, 2021, 01:43
Hello! I made a topic about this issue on the forum but I was recommended to post it here as well. When I'm outputting the date in my calendar, Fantasy Grounds is adding the wrong suffix to certain days of the month. Specifically, it is changing the 11th, 12th, and 13th to the 11st, 12nd, and 13rd respectively. What is causing this and is there any solution to fix it? I have attached a screenshot illustrating the error.

I'm not seeing anything in that screenshot like what you describe. Are you seeing it in the chat output? The chat output for a date is typically formatted in the CalendarManager.getDateString() function. It gets the last digit of the day number, and then references one of the 10 strings "message_calendarsuffix" 0-9. This returns the suffix "th", "st", "nd", or "rd".

So if you are getting something other than that behavior, you must have changed either the display function or strings.

Can you give any more detail on how you have your calendar set up. Do you have any custom calendar extension in use?

CallMeTheFalcon
October 25th, 2021, 03:32
I'm not seeing anything in that screenshot like what you describe. Are you seeing it in the chat output?

So if you look at the screenshot, specifically in the "Date" category, it lists the date as "Arnesmer, 13rd Mared" instead of "Arnesmer, 13th Mared," with 13rd being the weird issue in this example.

I'm also using a custom calendar extension, which I have included in the attached zip file.

mattekure
October 25th, 2021, 03:39
So if you look at the screenshot, specifically in the "Date" category, it lists the date as "Arnesmer, 13rd Mared" instead of "Arnesmer, 13th Mared," with 13rd being the weird issue in this example.

I'm also using a custom calendar extension, which I have included in the attached zip file.

Ok, I see what you mean. I took a look at your zip file, specifically the Faustacian Calendar.lua file and I think I see the issue. You are using a leap year system where it adds a day every 4 years. Your calcMyMonthVar() function does that correctly. However, your calcMyLunarDay() function does not take leap years into calculation. So when it is calculating what day of the week it is, it will start to go off for every leap year that has passed. In your screenshot its year 1632, which by your rule of every 4 years would mean adding 408 days for your calculation to be correct. So in your calcMyLunarDay() you would need to account for that by including something like


function calcMyLunarDay(nYear, nMonth, nDay)
local rYear = nYear * 365;
local rMonth = nMonth-1;
local rMonthDays = rMonth * 30;
local rLeapDays = math.floor(nYear/4);
local rDay = (rYear + rMonthDays + nDay+rLeapDays)%7;
if rDay == 0 then
return 7;
end
return rDay
end

CallMeTheFalcon
October 25th, 2021, 04:00
Thanks for looking into this! I went ahead and updated the calcMyLunarDay() function in the lua file, but I'm still getting the same issue with the 11th, 12th, and 13th of each month being displayed as "11st, 12nd, and 13rd" respectively. I've included the screenshot of the error and how it appears in my calendar as well as a zip containing the extension files in case I did something wrong replacing the code.

mattekure
October 25th, 2021, 04:10
Thanks for looking into this! I went ahead and updated the calcMyLunarDay() function in the lua file, but I'm still getting the same issue with the 11th, 12th, and 13th of each month being displayed as "11st, 12nd, and 13rd" respectively. I've included the screenshot of the error and how it appears in my calendar as well as a zip containing the extension files in case I did something wrong replacing the code.

can you post your calendar mod file. I'll take a closer look at it tomorrow

CallMeTheFalcon
October 25th, 2021, 04:25
Sure!

mattekure
October 25th, 2021, 14:28
Sure!

Ok, there is still a calculation issue. I'll post my edits in a little bit. But the error you are reporting with the 11, 12, and 13 is actually an error in CoreRPG calendar code. I will create a thread over on the FGU support forum to bring it to the devs attention.

EDIT: Error thread posted here https://www.fantasygrounds.com/forums/showthread.php?71080-CoreRPG-Calendar-Date-Display-Issue&p=624705#post624705

mattekure
October 25th, 2021, 14:54
Sure!

OK, I've fixed the calculation issue you were having. Its the primary reason the days of the week would not line up around your intercalary month. Here is the resulting function. The calculation you were missing was accounting for the fact that there was a month that didnt have 30 days, but you were calculating as if every month had 30 days. So during the year, if the date comes after the intercalary month, you need to subtract either 25 days, or 24 if its a leap year since that month is either 5 or 6 days long.



function calcMyLunarDay(nYear, nMonth, nDay)
local rYear = nYear * 365;
local rMonth = nMonth-1;
local rMonthDays = rMonth * 30;
if nMonth >=8 then
if nYear % 4 == 0 then
rYear = rYear - 24
else
rYear = rYear - 25;
end
end
local rLeapDays = math.floor(nYear/4);
local rDay = (rYear + rMonthDays + nDay+rLeapDays)%7;
if rDay == 0 then
return 7;
end
return rDay
end

CallMeTheFalcon
October 25th, 2021, 23:26
Thanks so much for the help!

ElzbethE
October 28th, 2021, 03:45
Okay, I accidentally deleted all of the OLD calendars while trying to add my custom one. Can anyone help me?

damned
October 28th, 2021, 04:01
The calendars are in a module file called calendars.mod

If you deleted that rerun the updater.
If you replaced it with your own version rename your file to something else and rerun teh updater.

dcanimate
January 12th, 2022, 19:56
This has been amazing and has allowed me to mostly model the imperial calendar for Warhammer Fantasy (crazy stuff with holidays not existing as days of the week or being numbered were ignored).

The one thing that I am trying to figure out now is if there is a way to change the formatting for multiple holidays falling on the same day. They are currently separated with a "/" and I would prefer that they are on different lines or separated with line breaks. Is this possible within the ext similar to how the date format can be changed? I have no idea how this would be accomplished.

mattekure
January 13th, 2022, 01:39
This has been amazing and has allowed me to mostly model the imperial calendar for Warhammer Fantasy (crazy stuff with holidays not existing as days of the week or being numbered were ignored).

The one thing that I am trying to figure out now is if there is a way to change the formatting for multiple holidays falling on the same day. They are currently separated with a "/" and I would prefer that they are on different lines or separated with line breaks. Is this possible within the ext similar to how the date format can be changed? I have no idea how this would be accomplished.

Thats doable with an extension, but a bit outside the scope of the calendar tutorial. You would need to redefine some of the calendar windowclasses. If you extract the CoreRPG ruleset, take a look at the utility/utility_calendar.xml file. that has all of the window definitions used in the calendar.

HyljeKlubi
February 1st, 2022, 15:40
I am having a problem with the calendar. I initially started to mod Example 2 - Simple Calendar, Holidays. All I need necessarily is to have 10 months with each having 41 days and the last day being holiday always. Either that or separate "holiday mini months" outside the normal month. So 40 + 1 + 40 + 1 etc. What happened is that I only changed the name of the first month to my needing and se the number of days and name of the holiday. It worked fine. All changes after that are not updated to fantasy grounds regardless of what i try. I obviously replace the .mod with fresh file, close and open fantasy grounds again, unload and load module, and reset calendar.

Even if I remove all the other sample months it still shows the "FifthMonth" etc samples there. With 28 days. Any insight what could I be doing wrong?

mattekure
February 1st, 2022, 15:44
I am having a problem with the calendar. I initially started to mod Example 2 - Simple Calendar, Holidays. All I need necessarily is to have 10 months with each having 41 days and the last day being holiday always. Either that or separate "holiday mini months" outside the normal month. So 40 + 1 + 40 + 1 etc. What happened is that I only changed the name of the first month to my needing and se the number of days and name of the holiday. It worked fine. All changes after that are not updated to fantasy grounds regardless of what i try. I obviously replace the .mod with fresh file, close and open fantasy grounds again, unload and load module, and reset calendar.

Even if I remove all the other sample months it still shows the "FifthMonth" etc samples there. With 28 days. Any insight what could I be doing wrong?

I assume you are trying to see these changes in the same campaign. When you select a calendar, it copies the information about the calendar (months, days, etc) into the campaign and does not reference the module after that. In order for you to see the change, you need to right click and reset the calendar, then reselect it.

If you still see the unexpected months after resetting and reloading, try posting the calendar mod here and I can take a look.

https://i.imgur.com/RPtUSGR.png

HyljeKlubi
February 1st, 2022, 16:02
I indeed did reset it every time I made changes. Here is the zip file (i rename it to mod obviously when putting to mod folder)

mattekure
February 1st, 2022, 16:07
I indeed did reset it every time I made changes. Here is the zip file (i rename it to mod obviously when putting to mod folder)

You have an error on line 22, the ending of the days tag is incorrect.

https://i.imgur.com/G6Kxmy5.png

fix that tag and the calendar works fine.

https://i.imgur.com/R7AuIOX.png

Artlox
February 16th, 2022, 14:24
Hi there!

Trying to create a calendar, 13 months, varying days and some holidays. Custom names. Nothing too fancy. Been trying to adapt one of the examples but I cant seem to get FG to recognise the module when I repack it. Any idea where i've gone wrong?

mattekure
February 16th, 2022, 15:11
Hi there!

Trying to create a calendar, 13 months, varying days and some holidays. Custom names. Nothing too fancy. Been trying to adapt one of the examples but I cant seem to get FG to recognise the module when I repack it. Any idea where i've gone wrong?

It wont load because your xml is invalid in the db.xml. You have a bunch of mismatched tags. Mostly the holidays tags. remember, the tags have to be paired like this. <holidays> </holidays> Mostly you have closing tags without the slash, so it appears like a new opening tag.

stuff like this


<holidays>
<holiday1>
<duration type="number">7</duration>
<name type="string">Festival of Blossoms</name>
<startday type="number">9</startday>
</holiday1>
<holidays> <-- this line needs a slash to close the first tag. </holidays>


This type of error appears multiple times through the db.xml.

LordEntrails
February 16th, 2022, 15:28
If you use an xml editor like Notepad++ and set the language to xml, you will quickly see these types of mismatched tags.

mattekure
February 16th, 2022, 15:31
yeah, with notepad++ you can get the xml tools plugin and check syntax with it. it also warns you if you save it and the syntax is wrong.

https://i.imgur.com/ie5o6q1.png

ChipDancer
February 16th, 2022, 21:37
Yup! As an It guy it's my go to tool! :)

PS: Great community support guys!

girlybits
April 13th, 2022, 00:14
The calendar is pretty straightforward. You can do it manually following this tutorial, or you can use my new method of using Donjon's Calendar utility to create the calendar, then my donjon2fg website to convert into a FG module. (Note, this process will not track the moons, just the months/weeks/days)

Donjons calendar creator utility https://donjon.bin.sh/fantasy/calendar/

My donjon2fg website https://mattekure.com/donjon2fg/

For the moons, have you checked out https://www.fantasygrounds.com/forums/showthread.php?46672-Andraax-Moon-Tracker-Extension? Its designed to track multiple moons on the calendar.


I went to use this today, the donjon2fg, but it looks like the site is down. Did I miss something?

Andrew Bradford
April 13th, 2022, 09:34
I edited the file and have my two .xml files ready to go but I move them into the module folder of unity and nothing happens. Can I have a more clear breakdown of where the files go?

Currently I am doing this...
1 Edit example db and definition .xml files
2 create copies elsewhere
3 move copies to fantasyground unity modules folder

I also tried using 7zip to zip the files (no fancy use of it, just a zip folder) then I renamed the zip file to Calendar Files.mod and moved it to the fantasy grounds unity module folder (I also tried moving the zip folder itself into there after the previous method did not work)

None of these have worked so far, what am I missing?

Marquis_de_Taigeis
April 13th, 2022, 12:56
unfortunately, there is a message earlier in this thread, but Mattekure no longer has donjon2fg as a working site, which was very sad when i went to use it a couple months back, that being said i found that altering the code for a calendar by unzipping and the example files FG provides and editing them in a coding program, it is fairly easy to code your own calendar

mattekure
April 13th, 2022, 13:45
I went to use this today, the donjon2fg, but it looks like the site is down. Did I miss something?

Yeah. The site is down and has been for some time.

mattekure
April 13th, 2022, 13:52
I edited the file and have my two .xml files ready to go but I move them into the module folder of unity and nothing happens. Can I have a more clear breakdown of where the files go?

Currently I am doing this...
1 Edit example db and definition .xml files
2 create copies elsewhere
3 move copies to fantasyground unity modules folder

I also tried using 7zip to zip the files (no fancy use of it, just a zip folder) then I renamed the zip file to Calendar Files.mod and moved it to the fantasy grounds unity module folder (I also tried moving the zip folder itself into there after the previous method did not work)

None of these have worked so far, what am I missing?

The only thing that stands out is that in your definition.xml file, you have the ruleset set to Opus Terra. I am not familiar with any ruleset named Opus Terra. It would be better to set the ruleset tag to "Any" so that the calendar can be used in any kind of ruleset. Also, for your zip mod. you zipped them up correctly, you just need to change the extension. so it would be CalendarFiles.mod not CalendarFiles.mod.zip. make those two changes and you should see the calendar file available to load in your module activation.

https://i.imgur.com/QAUoAtU.png

Andrew Bradford
April 13th, 2022, 19:56
The only thing that stands out is that in your definition.xml file, you have the ruleset set to Opus Terra. I am not familiar with any ruleset named Opus Terra. It would be better to set the ruleset tag to "Any" so that the calendar can be used in any kind of ruleset. Also, for your zip mod. you zipped them up correctly, you just need to change the extension. so it would be CalendarFiles.mod not CalendarFiles.mod.zip. make those two changes and you should see the calendar file available to load in your module activation.

https://i.imgur.com/QAUoAtU.png

So I've followed the above steps with no luck still, I have the .mod file in my modules folder

mattekure
April 13th, 2022, 20:36
So I've followed the above steps with no luck still, I have the .mod file in my modules folder

You need to put the ruleset as "Any", not "any" in the definitions file.

Andrew Bradford
April 13th, 2022, 20:49
Did that, still not showing up

mattekure
April 13th, 2022, 20:58
Did that, still not showing up

What did you use to zip that mod file up? It gave me errors when I tried to extract it. Try this attached one.

Andrew Bradford
April 13th, 2022, 21:03
What did you use to zip that mod file up? It gave me errors when I tried to extract it. Try this attached one.

The attached file worked, thank you. I was just using windows 10 and right clicking the two xml files and pressing "Add to Calendar Files.rar" so I probably wasn't properly zipping them.

mattekure
April 13th, 2022, 21:08
Yeah, rar is not the same as zip. you can use the window 10 but make sure you use the proper zip file selection.

https://i.imgur.com/KlGVdEa.png

Gutts D. Freecss
June 12th, 2022, 17:14
Hi! New "coder" here! I'm trying to make a custom calendar work in FGU, and I used one of your exemples to make it work. Thanks you for your help! I don't know what I did wrong, but I can't see the extension or the mod in FGU... I put the .mod in the mod folder and the .ext in the extensions folder. I (think) I've attached the .ext and .mod files... Can anyone give me a hand and see what is wrong with the coding. (or anything else that I'm doing...)

5311053111

mattekure
June 12th, 2022, 17:16
Hi! New "coder" here! I'm trying to make a custom calendar work in FGU, and I used one of your exemples to make it work. Thanks you for your help! I don't know what I did wrong, but I can't see the extension or the mod in FGU... I put the .mod in the mod folder and the .ext in the extensions folder. I (think) I've attached the .ext and .mod files... Can anyone give me a hand and see what is wrong with the coding. (or anything else that I'm doing...)

5311053111

In both cases, the reason is that you included the parent folder in the zip file. only include the files in the folder, not the folder itself.

Gutts D. Freecss
June 12th, 2022, 17:39
Yep! That was it... Thanks!

JShadow007
August 6th, 2022, 20:02
Amazing tutorials, and super surprised to see that the calendar that got made for my campaign years ago (by you?) wound up as an example :)

Giving it a shot with the calendar from Ptolus for an upcoming game.

JShadow007
August 6th, 2022, 20:40
I'm getting an error message when i try to load in the module i made based off of some of your examples. Any idea what I'm doing wrong here? Was trying to use your generic lunar extension with this.

mattekure
August 6th, 2022, 20:50
I'm getting an error message when i try to load in the module i made based off of some of your examples. Any idea what I'm doing wrong here? Was trying to use your generic lunar extension with this.

you are missing a >

https://i.imgur.com/COH9PcC.png

JShadow007
August 6th, 2022, 21:23
Feeling dumb. cant believe i missed that!

should have tossed it onto bbedit on my mac to see the code better.

Thank you!

ChipDancer
August 11th, 2022, 22:32
No biggie JShadow007, we all make stupid mistakes! :)

Kutos to Mattekura-sama for finding it! :)

ChipDancer

Kuragiman
August 13th, 2022, 17:21
Just wanted to say thanks for the tutorial. It was very straight forward. I was able to transfer my world's calendar with all the holidays into FGU from my old VTT platform. Combine this with the Moon Tracker extension and my players are once again immersed in the world just a little bit more. Thanks!

ChipDancer
August 15th, 2022, 22:06
So far my calendar is right where I want it for the most part as seen below:
53975

I am also trying to figure out how to change it so that the name of the months is on two lines instead of one as seen in this example:
53976

Any ideas would be greatly appreciated as I continue to chug along! :)

ChipDancer

ChipDancer
August 15th, 2022, 22:18
For those of you wanting to correct where the days 11,13, & 23 have the wrong suffix all you have to do is add a few lines to the strings.common.xml file inside the corerpg.pak file (just rename it to .rar and extract to it's own folder). It's in the strings folder.

<!--*******************************-->
<!-- Here sets the date suffix! -->
<!--*******************************-->

<string name="numbersuffix0">th</string>
<string name="numbersuffix1">st</string>
<string name="numbersuffix2">nd</string>
<string name="numbersuffix3">rd</string>
<string name="numbersuffix4">th</string>
<string name="numbersuffix5">th</string>
<string name="numbersuffix6">th</string>
<string name="numbersuffix7">th</string>
<string name="numbersuffix8">th</string>
<string name="numbersuffix9">th</string>
<string name="numbersuffix11">th</string> <!-- Add this line -->
<string name="numbersuffix13">th</string> <!-- Add this line -->
<string name="numbersuffix23">rd</string> <!-- Add this line -->
<string name="numbersuffix_default">th</string>

ChipDancer

WinterSoldier7
August 17th, 2022, 15:21
I have to say, I am very proud of my calendar. It took a fair bit of muddling through, because I had no idea how to use Notepad++ at first... but now I've dun a thing and I'm very pleased. Thanks for this tutorial, could not have done it without.

Would you, or anyone, happen to know how the calendars in FGU actually work? Before I introduce my calendar to my PCs, I'd like to know what features it has;

- Does it have any functionality with regards to long rests?
- Can I make the calendar bigger??
- What does the era section mean? Is that just a name?
- Does the clock timer do anything, or is it just a signal to PCs?

Thanks

mattekure
August 17th, 2022, 16:02
I have to say, I am very proud of my calendar. It took a fair bit of muddling through, because I had no idea how to use Notepad++ at first... but now I've dun a thing and I'm very pleased. Thanks for this tutorial, could not have done it without.

Would you, or anyone, happen to know how the calendars in FGU actually work? Before I introduce my calendar to my PCs, I'd like to know what features it has;

- Does it have any functionality with regards to long rests?
No, but there is the Clock Adjuster extension which integrates functionality like advancing time on a rest. https://forge.fantasygrounds.com/shop/items/574/view
- Can I make the calendar bigger??
Possible with an extension. You would have to dig into the CoreRPG files that define the layout of the calendar. Probably not trivial.
- What does the era section mean? Is that just a name?
Its just a name. you can have it represent whatever you want, like BC, AD, etc.
- Does the clock timer do anything, or is it just a signal to PCs?
I'm not sure what you mean by the clock timer. There are time fields, but they dont do anything unless you have the Clock Adjuster extension.
Thanks

I think that covers all your questions

ChipDancer
August 17th, 2022, 16:16
I have to say, I am very proud of my calendar. It took a fair bit of muddling through, because I had no idea how to use Notepad++ at first... but now I've dun a thing and I'm very pleased. Thanks for this tutorial, could not have done it without.

Would you, or anyone, happen to know how the calendars in FGU actually work? Before I introduce my calendar to my PCs, I'd like to know what features it has;

- Does it have any functionality with regards to long rests?
- Can I make the calendar bigger??
- What does the era section mean? Is that just a name?
- Does the clock timer do anything, or is it just a signal to PCs?

Thanks

I created my campaign's calendar to add a bit or realism to the overall game. The dates, holidays, season, etc.. are all part of that overall atmospheric effect. The fact that both players and the GM can leave notes on specific days makes it an interesting tool and when you tie in the moon(s) phase functionality you gain further depth!

(^_^)

ChipDancer

WinterSoldier7
August 17th, 2022, 17:14
@mattekure - thank you so much for the response!


The fact that both players and the GM can leave notes on specific days makes it an interesting tool and when you tie in the moon(s) phase functionality you gain further depth!

I did notice that there was a section for GM and PLAYERS, but had hoped it was somewhere I could enter events that I could see and ones only my PCs could see - is that not the case?

Nylanfs
August 17th, 2022, 17:47
Make a story, then in the calendar say See Story #X

mattekure
August 17th, 2022, 18:13
@mattekure - thank you so much for the response!



I did notice that there was a section for GM and PLAYERS, but had hoped it was somewhere I could enter events that I could see and ones only my PCs could see - is that not the case?

You can make entries that are visible to GM only, or Visible to Players. But by default, players cannot add entries. I believe there are extensions that make it possible. As Nylanfs mentioned, you can link story entries or notes for more details but it requires the DM to set up the link.

WinterSoldier7
August 17th, 2022, 18:30
Ah, that's preferred.

Brill, will give this a play around for my next session then. Thanks!

Sulimo
August 17th, 2022, 18:32
If you are looking for an extension that allows players to enter details, try out Player Agency, it adds the Calendar piece, and a couple of other items.

Marquis_de_Taigeis
August 18th, 2022, 20:25
i was thinking about creating an excel macro that would auto create the code for copy and pasting in to the mod files, if any one is interested in this let me know

LordEntrails
August 18th, 2022, 21:08
i was thinking about creating an excel macro that would auto create the code for copy and pasting in to the mod files, if any one is interested in this let me know
I've been curious about this possibility and would love to see a working example. I poked at doing this years ago (but not for a calendars) but never figured it out.

ChipDancer
August 22nd, 2022, 16:47
Grrrr!

I had to reload CoreRPG.pak due to some corruption and it messed my calendar up! ARG!!!
I had notes on every step except one, which to my shame, I forgot to log as it was the last thing I figured out, the weekday.

I got everything, well almost everything back to normal, but for some reason only two of my days show up properly now like in this photo:

54068

The other five days are showing up as such:

54069

Here is my code from the mod file for the names of the weekdays:

<lunardaycalc type="string">Twilight</lunardaycalc>
<lunarweek>
<day1 type="string">Resdor</day1>
<day2 type="string">Sendor</day2>
<day3 type="string">K'zyldor</day3>
<day4 type="string">Mildor</day4>
<day5 type="string">T'yandor</day5>
<day6 type="string">Freldor</day6>
<day7 type="string">Cel'myrdor</day7>
</lunarweek>

Note: Only days six and seven are showing up.

Here is the function block from the manager_calendar.lau from the CoreRPG.pak file function that I customized:

function getDateString(sEpoch, nYear, nMonth, nDay, bAddWeekDay, bShortOutput)
local sDateFormat = DB.getValue("calendar.data.dateformat");
if sDateFormat and aDateDisplay[sDateFormat] then
return aDateDisplay[sDateFormat](sEpoch, nYear, nMonth, nDay, bAddWeekDay, bShortOutput);
end

local sMonth = CalendarManager.getMonthName(nMonth);
local sDay = StringManager.ordinalize(nDay);

local sOutput;
if bShortOutput or (nYear == 0) then
sOutput = sDay .. " " .. sMonth;

--*************************************************--
-- This is where I am testing my custom variable! --
--*************************************************--

else
sOutput = " the "..sDay .. " day of " .. sMonth .. ", Year " .. nYear .. ", Era of " .. sEpoch;
end

if bAddWeekDay then
local nWeekDay = CalendarManager.getLunarDay(nYear, nMonth, nDay);
local sWeekDay = CalendarManager.getLunarDayName(nWeekDay);
sOutput = sWeekDay .. ", " .. sOutput;
end
return sOutput;
end


Any help would be most appreciated! :)

ChipDancer

damned
August 22nd, 2022, 22:29
Please try with the ' in the names?
Also please dont edit CoreRPG.pak - this file gets regularly updated - you should make your calendar in a mod/ext.

mattekure
August 23rd, 2022, 02:05
I'll echo what Damned said. Never edit the corerpg.pak directly. it gets updated and will wipe out whatever you do. Instead, create an extension for your code and register it. In your code, you can set up your custom handlers by using the following functions.

CalendarManager.registerLunarDayHandler() - used to override the default behavior of calculating what day of the week it is: used instead of getLunarDay()
CalendarManager.registerMonthVarHandler() - used to override the default behavior of how many days in a month: used instead of getDaysInMonth()
CalendarManager.registerDayDisplayHandler() - Used to override the default behavior of how to format the day value: used instead of getDayString()
CalendarManager.registerDateDisplayHandler() - used to override the default behavior of how to format the date string: used instead of getDateString()

ChipDancer
August 23rd, 2022, 15:20
Mattekure,

I hate to bother you, but could you please take a look at my calendar mod for me? I simply cannot see what was changed and I'm betting it's something stupid, but I'm not seeing any code errors that are obvious. I would be most appreciated.



ChipDancer

mattekure
August 23rd, 2022, 17:16
Mattekure,

I hate to bother you, but could you please take a look at my calendar mod for me? I simply cannot see what was changed and I'm betting it's something stupid, but I'm not seeing any code errors that are obvious. I would be most appreciated.



ChipDancer

Question, does your calendar have leap years?

mattekure
August 23rd, 2022, 18:07
Mattekure,

I hate to bother you, but could you please take a look at my calendar mod for me? I simply cannot see what was changed and I'm betting it's something stupid, but I'm not seeing any code errors that are obvious. I would be most appreciated.



ChipDancer

The only issue I observed was in the extension itself, and likely stems from not understanding the purpose of the function. The LunarDayHandler that is registered is designed to return a number representing the day of the week, with 1 being the first day of the week. By default, the calendar starts at Year 0, Day 1 which is set on the first day of the week. In order to properly calculate what day of the week Thursday, May 5, 2082 falls on, we run through a series of calculations to sum up all the days from year 0 day 1, to the targeted date. See comments in code below



function calcTwilightLunarDay(nYear, nMonth, nDay)
local rYear = nYear * 362; -- Since we know that every year contains 362 days on this calendar, we can calculate the total number of days since year 0 by multiplying the current year by 362. That gives us the number of days up to the first day of the current year.
local arrayMonthDays = {0,28,58,89,120,150,178,209,239,269,300,331,362}; -- you do not need the last entry 362 as that number will never be reached. if you ever hit it, you would be restarting at a new year at 0.
-- These next three lines are not needed.
if (nMonth == 0) then
nMonth = 1; --sets current month?
end
-- We use the nMonth variable as an indices to the arrayMonthDays table to determine the number of days that have occurred up to the current month.
local rMonthDays = arrayMonthDays[nMonth];
-- The following line calculates the total number of days since Year 0 Day 1. It has rYear and rMonthDays calculated above, which are the number of days up to the first of the current month, and nDay which is the day of the current month. Adding them all together gives us the total number of days. The week is exactly 7 days long, and starts on day 0. So we use the modulus operator to get a number 0-N which represents the day of the week. This does not have anything to do with spacing.
local rDay = (rYear + rMonthDays + nDay)%7; --not sure what this does yet, but looks to control vertial column spacing ???
-- The following is incorrect because you are adding additional days beyond the week definition of 7. with this code, The first day of the month would fall on the 7th day of the week, and so on. So you end up with weird blank weeks.
return (rDay+6); --sets start day of the year
end


A simple fix that appears to work is as follows.



function calcTwilightLunarDay(nYear, nMonth, nDay)
local rYear = nYear * 362; -- Calculate the total number of days from Year 0 to First day of current year.
local arrayMonthDays = {0,28,58,89,120,150,178,209,239,269,300,331}; -- index to lookup number of days passed this year up to the current month, but not including the current month.
local rMonthDays = arrayMonthDays[nMonth]; -- lookup the number of days passed in the current year up to the current month.
local rDay = (rYear + rMonthDays + nDay)%7; -- Add up all the days from the years, months, and days of the current month to get the grand total number of days from Year 0 Day 1 to Current Year/Month/Day. Use the % operator to divide the total number of days by the number of days in a week
if rDay == 0 then
rDay = 7 -- this ensures that we are working with day of the week values from 1-7 and not 0-6. In this instance, a modulus of 0 means that it is the exact number of days in a week, so represents the last day of the week.
end
return rDay; -- return the value 1-7 of which day of the week that the date specified in nYear/nMonth/nDay should fall on.
end


With this code, I get a calendar that looks like this.
https://i.imgur.com/6wHtKuZ.png

ChipDancer
August 23rd, 2022, 19:30
You sir rock!

Thank you so very much for pointing that out as I had been focused on thinking it was the mod file! LOL!!!

(^_^)

'bows low'

ChipDancer

ChipDancer
August 26th, 2022, 21:28
I was rereading one of the posts in this thread and thought wouldn't it be interesting if there was a mod/ext for generating weather with your calendar. Anyone know if such exists?

Thanks in advance,

ChipDancer

mattekure
August 26th, 2022, 21:30
I was rereading one of the posts in this thread and thought wouldn't it be interesting if there was a mod/ext for generating weather with your calendar. Anyone know if such exists?

Thanks in advance,

ChipDancer

There is an extension for doing weather, but it doesnt currently tie into the calendar. Its the only weather generator I know of.

https://www.dmsguild.com/product/360100/Fantasy-Grounds-Unity-Weather-Generator?affiliate_id=712946

ChipDancer
August 26th, 2022, 21:46
Mattekura-sama,

You continue to be invaluable aid to this community!

Thank you!

ChipDancer

Saeheris
December 14th, 2022, 15:31
Wonderful guide!

thank to you i created my personal calendar.

Can i ask two things?

1) do you know if is possible to have a day outside the month and the weekday name? for now i created a period one day long, but i cannot free this day from the weekday name.

2) Fgu calendars can display season or can it create named group of month/period?

Sorry for my awful english

mattekure
December 14th, 2022, 16:35
Wonderful guide!

thank to you i created my personal calendar.

Can i ask two things?

1) do you know if is possible to have a day outside the month and the weekday name? for now i created a period one day long, but i cannot free this day from the weekday name.

2) Fgu calendars can display season or can it create named group of month/period?

Sorry for my awful english

there is no way to have a day outside a month/weekday name, but you can create a month that is only 1 day long. There is no way to free it from the weekday name.

There is no mechanism to display season. You could implement them as holidays. Create a holiday that spans the length of the season. You might have to have a separate holiday definition for each month as they do not span months.

Saeheris
December 15th, 2022, 08:11
wow thank for the fast reply, it's not a bad idea the holiday for create the season, but i think that for now i'll modify the name of the month by adding the season, fortunately i created a simple calendar.

like always, mr mattekure, you are very kind and knowdgeable. thank a lot for sharing with us.

hazeyindahead
May 14th, 2023, 16:36
57353

How do I fix the current month not displaying? It disappears when the month becomes current, I tried searching and looking into why it wont appear in the xml file and the forum thread, sorry if this is mentioned already.

GunnarGreybeard
May 14th, 2023, 17:05
Is that one that you created/modified? I have on I've made for HârnWorld and am not seeing that behavior. Maybe the current month font color is set to black??

hazeyindahead
May 14th, 2023, 19:01
Hi, yes I made this one myself and was wondering if I was missing a tag or property in the file. I also noticed that the holidays are blanked out.

I suppose the color could be an issue with the dark theme (using the Hearth) but is there a way I can fix it in the DB file for calendars?

GunnarGreybeard
May 14th, 2023, 19:59
I tried the Hearth theme and it did the same to my calendar. You'll probably need to edit the theme to use other colors. I'm not sure a separate extension would work unless it's not already something in the Hearth theme that could be edited.

hazeyindahead
May 14th, 2023, 22:04
Ok, thakn you for troubleshooting, its not an issue with the calendars plugin! :)

Berwind
June 2nd, 2023, 03:25
I've been having issues adding leap years to my calendar.
I'm trying to do something similar to the Gregorian, but extra days on years that are multiples of two (instead of four), not multiples of 10 (instead of 100) except for multiples of 50(instead of 400).
Unfortunately, the extra days are not being added.
Experimentally, I've tried applying rollover days and that appears to work, however I do not want them.

mattekure
June 2nd, 2023, 13:54
I've been having issues adding leap years to my calendar.
I'm trying to do something similar to the Gregorian, but extra days on years that are multiples of two (instead of four), not multiples of 10 (instead of 100) except for multiples of 50(instead of 400).
Unfortunately, the extra days are not being added.
Experimentally, I've tried applying rollover days and that appears to work, however I do not want them.

You are missing a <periodvarcalc> tag in your module db.xml.

For example, in the gregorian calendar you have both a lunardaycalc tag so that the days of the week line up correctly on the calendar (ie, if Feb 28 is a Wed, then Mar 1 is a Thur). And it has a periodvarcalc to add days to Feb when the conditions are correct.



<lunardaycalc type="string">MKgregorian</lunardaycalc>
<lunarweek>
<day1 type="string">Sunday</day1>
<day2 type="string">Monday</day2>
<day3 type="string">Tuesday</day3>
<day4 type="string">Wednesday</day4>
<day5 type="string">Thursday</day5>
<day6 type="string">Friday</day6>
<day7 type="string">Saturday</day7>
</lunarweek>
<periodvarcalc type="string">MKgregorian</periodvarcalc>



Your code only has a lunardaycalc, which is never being used/called because you are not registering a lunar day handler. you are registering a monthvar handler which should be defined in the periodvarcalc tag. I recommend you rename the lunardaycalc tag to periodvarcalc and it should start adding the leap years according to your code.

Berwind
June 2nd, 2023, 22:13
You are missing a <periodvarcalc> tag in your module db.xml.

For example, in the gregorian calendar you have both a lunardaycalc tag so that the days of the week line up correctly on the calendar (ie, if Feb 28 is a Wed, then Mar 1 is a Thur). And it has a periodvarcalc to add days to Feb when the conditions are correct.



<lunardaycalc type="string">MKgregorian</lunardaycalc>
<lunarweek>
<day1 type="string">Sunday</day1>
<day2 type="string">Monday</day2>
<day3 type="string">Tuesday</day3>
<day4 type="string">Wednesday</day4>
<day5 type="string">Thursday</day5>
<day6 type="string">Friday</day6>
<day7 type="string">Saturday</day7>
</lunarweek>
<periodvarcalc type="string">MKgregorian</periodvarcalc>



Your code only has a lunardaycalc, which is never being used/called because you are not registering a lunar day handler. you are registering a monthvar handler which should be defined in the periodvarcalc tag. I recommend you rename the lunardaycalc tag to periodvarcalc and it should start adding the leap years according to your code.

That was it. I was so focused on the LUA I didn't catch my mistake in the db.XML.
Thanks for the extra set of eyes!

Deathloc
June 7th, 2023, 00:09
I want to do the Mayan calendar which has two calendars that interlink and the same day combination only repeats every 52 years.

mattekure
June 9th, 2023, 02:26
I want to do the Mayan calendar which has two calendars that interlink and the same day combination only repeats every 52 years.

There is no way currently to run two calendars. You would have to write an extension to add that functionality

Mach5RR
July 3rd, 2023, 03:32
Out of curiosity, does anyone know how to do a month with two different lengths of the week (7 day/8 day)?

We have a setting that has a 7 day week, a fortnight which consists of two weeks with a Festival day inbetween, and a month that consists of two fortnights (30 days). I figured the easiest way is to code the first and third week as 8 days, and the 2nd and 4th as 7 day weeks.
Right now, our workaround is to just make a 15 day week, with seven of the days repeating themselves. But this is ... inelegant to look at.

GM Ithril
January 3rd, 2024, 23:20
How many moons can this track?

mattekure
January 3rd, 2024, 23:23
How many moons can this track?

This thread is about creating custom calendars, it does not do anything with moons. You might get better answers with this moon tracking extension. https://forge.fantasygrounds.com/shop/items/172/view

GM Ithril
January 3rd, 2024, 23:42
I was under the impression that the lunar day handler had a lunar tracking function?
Also, will that extension handle 'moons' whose period is greater than a year?

mattekure
January 3rd, 2024, 23:50
I was under the impression that the lunar day handler had a lunar tracking function?

Ah, super easy mistake to make, and mostly my fault. Too much code on the brain when I named it. Inside the FG calendar system is a function which returns the day of the week a particular date falls on. So for example, if you were to pass it the Mar 3, 1542, it would return some value which represents Sun-Sat. That function is called a lunar day handler (I dont know why, I didnt name it) and has nothing to do with the moon. The extension attached is a generic form of that function which allows for calendars without leap years to easily calculate what day of the week a particular date falls on. Without it, each calendar would have to include its own custom extension with this function defined.

LordEntrails
January 3rd, 2024, 23:52
Also, will that extension handle 'moons' whose period is greater than a year?
Questions about the Moon Tracker extension should be asked in the thread for that extension. It has a different community developer. You can find the thread for a given extension by looking at the top left corner of the extension's page and then follow the link there for "Forum Thread". BMOS, the developer for the Moon Tracker extension should be able to answer this question for you :)

GM Ithril
January 3rd, 2024, 23:53
Thank You very much for the clarification.
Will the extension you linked handle 'moons' with a period greater than the number of day sin a year?
I'm working on a fairly complex 'elven' calendar to coincide with my 'human' calendar. It's probably much more ambitious of a calendar system than someone with the little bit of experience I have should be attempting.

mattekure
January 3rd, 2024, 23:54
Thank You very much for the clarification.
Will the extension you linked handle 'moons' with a period greater than the number of day sin a year?
I'm working on a fairly complex 'elven' calendar to coincide with my 'human' calendar. It's probably much more ambitious of a calendar system than someone with the little bit of experience I have should be attempting.

No idea, try asking on the extensions thread.

GM Ithril
January 3rd, 2024, 23:55
Questions about the Moon Tracker extension should be asked in the thread for that extension.

Whoop! Posted while I was typing. Thank you for that answer. I will seek further information there.

GM Ithril
January 4th, 2024, 00:48
Am I doing something wrong? I've added the modules, unloaded the standard calendar, and loaded a modified calendar, but when I access the calendar, it shows a Gregorian calendar, with the New Years and Christmas as designated holidays; and the current date as Tuesday the 0th.

Nevermind...
I didn't realize there's a command to reset the calendar that lets you pick the calendar to use.

ZelectheUnheard
January 10th, 2024, 09:16
mattekure, is there any way you know of to code a simple calendar with a 1 week holiday at the beginning of every two months, that uses a 26hr day? Everything else about time is the same, except 26 hours per day.

for more context, the following is the setup.

8 months per year,
45 days per month divided into 9 weeks of 5 days,
with 26 hours per day, there is a lore reason for an extra hour each day and night.

mattekure
January 11th, 2024, 12:49
mattekure, is there any way you know of to code a simple calendar with a 1 week holiday at the beginning of every two months, that uses a 26hr day? Everything else about time is the same, except 26 hours per day.

for more context, the following is the setup.

8 months per year,
45 days per month divided into 9 weeks of 5 days,
with 26 hours per day, there is a lore reason for an extra hour each day and night.

The whole months/weeks/days part is straightforward. Its just a simple calendar and the tutorial covers exactly how to do that. Making it handle 26 hours per day would require an extension. Essentially you would have to overwrite the CalendarManager.adjustHours(n) function to use 26 instead of 24.

I think the extension would only need to consist of 2 files, the extension.xml and a single lua file with code something like this



function onTabletopInit()
CalendarManager.adjustHours = myAdjustHours;
end

function myAdjustHours(n)
local nAdjHours = DB.getValue("calendar.current.hour", 0) + n;

local nDayAdj = 0;

if nAdjHours >= 26 then
nDayAdj = math.floor(nAdjHours / 26);
nAdjHours = nAdjHours % 26;
elseif nAdjHours < 0 then
nDayAdj = -math.floor(-nAdjHours / 26) - 1;
nAdjHours = nAdjHours % 26;
end

if nDayAdj ~= 0 then
CalendarManager.adjustDays(nDayAdj);
end

DB.setValue("calendar.current.hour", "number", nAdjHours);
end

ZelectheUnheard
January 24th, 2024, 00:30
I am trying to create the .mod and the .ext file. I have tried zipping the individual files, and I cant get it to work with my 7ip. might be user error though. was wondering if there was any good tutorial videos or whatnot on how to do it?

LordEntrails
January 24th, 2024, 00:37
I am trying to create the .mod and the .ext file. I have tried zipping the individual files, and I cant get it to work with my 7ip. might be user error though. was wondering if there was any good tutorial videos or whatnot on how to do it?
You're not zipping the containing folder right? And when using 7zip, you have to use .zip compression, not .7z compression. If you are still having trouble, try using native windows compression.

Zacchaeus
January 24th, 2024, 09:23
I am trying to create the .mod and the .ext file. I have tried zipping the individual files, and I cant get it to work with my 7ip. might be user error though. was wondering if there was any good tutorial videos or whatnot on how to do it?

To create a module from a folder first select the contents of the folder (this will be the xml files and any graphics folders). Once you have selected all of the contents right click and select send to and then on compressed file. This will create the .zip file. Rename the .zip to .mod to create the mod file. Other things to note is that the definition.xml file will contain the ruleset name. Make sure that this reads either Any or the specific ruleset that you are using. FG will not read a 7z file nor any other type of zipped file other than .zip; so just use the built in Windows zipper.

ScooterZ
March 30th, 2024, 16:56
Sorry, late to the party and I have not reviewed any files yet as the campaign world along with the calendar are still being worked on, BUT what you said here. Would that be just the case for a Gregorian calendar with US holidays? Specifically in mind is the US Thanksgivings Day being the (correct me if I'm wrong) 4th Thursday in November. I haven't looked at the Gregorian file, maybe it doesn't include this? Just a thought.

LordEntrails
March 30th, 2024, 19:46
Sorry, late to the party and I have not reviewed any files yet as the campaign world along with the calendar are still being worked on, BUT what you said here. Would that be just the case for a Gregorian calendar with US holidays? Specifically in mind is the US Thanksgivings Day being the (correct me if I'm wrong) 4th Thursday in November. I haven't looked at the Gregorian file, maybe it doesn't include this? Just a thought.
The Gregorian calendar that comes with FG does not include Thanksgiving. It's a uniquely US holiday so I'm sure it was left out intentionally. But I don't know exactly what part of Mattekure's post you are referring to. He's provided lost of detailed advice through the pages :)

ScooterZ
March 30th, 2024, 21:24
Sorry, that means i should have quoted something. I was reading a number of posts about the calendar. I had read there was no way to program the calendar file to include holidays falling on a particular day, which if your answer was different and US Turkey day was included would have been relevant, but since I didn't even look at the calendar, I hadn't discovered this on my own. Thank you for your response.

PaulChatterton
April 27th, 2024, 00:16
I have a custom calendar where there are 30 days per month comprising a holiday on the 1st and the 30th, and four 7-day weeks in between. All simple enough so far. However, the usual weekdays don't apply on the 1st and 30th, which have their own names, i.e.

Aurisday 1st

Aeraday 2nd
Thenceday 3rd
Hydriaday 4th
Yrtaday 5th
Gelithday 6th
Henceday 7th
Pyrosday 8th

Aeraday 9th
Thenceday 10th
...
Pyrosday 29th

Ouraniaday 30th

Is it possible to break up the weekday names like that, rather than having a steady cadence throughout the year?

mattekure
April 27th, 2024, 01:02
I have a custom calendar where there are 30 days per month comprising a holiday on the 1st and the 30th, and four 7-day weeks in between. All simple enough so far. However, the usual weekdays don't apply on the 1st and 30th, which have their own names, i.e.

Aurisday 1st

Aeraday 2nd
Thenceday 3rd
Hydriaday 4th
Yrtaday 5th
Gelithday 6th
Henceday 7th
Pyrosday 8th

Aeraday 9th
Thenceday 10th
...
Pyrosday 29th

Ouraniaday 30th

Is it possible to break up the weekday names like that, rather than having a steady cadence throughout the year?

that functionality is not supported by the current calendar code.