PDA

View Full Version : ELI5: Customizing a Calendar



Wolfheart
October 7th, 2017, 09:13
Hey all, I've been writing an ELI5 (Explain to Me Like I'm Five) for people who wish to have their own custom calendar in Fantasy Grounds but are intimidated or not sure what to do. I am in no way a tech guru so hopefully it's written in a way that can be helpful. It's a step-by-step guide that covers how to modify an existing calendar, not build one from the ground up. Give me a shout if anything is unclear, or wrong, or whatever.



1. Download (if you haven't already) Notepad++ here: https://notepad-plus-plus.org/download/ (1. Download (if you haven't already) Notepad++ here: https://notepad-plus-plus.org/download/)

2. Download (if you don't have it already) WinZip or similar software: https://www.winzip.com/win/en/downwz.html (2. Download (if you don't have it already) WinZip or similar software: https://www.winzip.com/win/en/downwz.html)

3. Install both programs to your computer.

4. Locate your Fantasy Grounds folder, the one with subfolders like "cache", "campaigns", "docs" etc. Its location depends on where you installed the program. If you have FG open, an easy way to get there is to open the Images window and click the "Folder" - button. It opens one of the subwindows in your main FG folder (you just need to 'move up' a few steps from there). My installation is in the folder "Program Data", which is a hidden file, so you'd need to set invisible files to visible if you have the same structure.

5. Open the "modules" folder by double-clicking it

6. Right-click and then click Copy on the menu or (ctrl+c) the "calendars" file. Make sure you don't (re)move it from the "modules"-folder! You want a copy of the file to tinker with, don't tinker with the original.


7. Paste the copied "calendars" file somewhere else, for example your desktop or in your Documents folder.

8. Click on the copied calendars file and hit F2 (or right-click and choose "Rename" on the menu) and add the following to the file name: .zip (It should now look like this: calendars.zip )

9. Right-click the file and choose "Open with…Winzip"

10. ((Note - I don't know if this is a new thing or not, but today while I was playing around with the files I could just right-click "calendars.mod" without renaming it to calendars.zip first - if you can edit a .mod-file directly without renaming it you save yourself an extra step later))

11. Winzip unpacks the file and shows you the three files that make up the zipped package: db.xml, definition.xml, and thumbnail.png. We'll start with the file named db.xml

12. Right-click the db.xml file and choose to open it with Notepad++. You may have to find it by using the "Search for an app.." feature that shows up.

13. Once you have it open, you will enter the file proper and this is where we get cracking. Here in the file's innards, you will see how calendars are structured (even I can see it - though the complexities of code are just a bit beyond me, it's easy to see the way it is set up).

14. If you scroll down the list of code, you'll see the name of each calendar embedded here, the uppermost being Gregorian Calendar. Since the Gregorian Calendar is the easiest to relate to we'll use this one to build a new calendar. Don't worry about all the code tags, we don't need to know everything to get this working.

15. Use the mouse to mark everything from <gregorian> to the next <gregorian>. To the left (if you use Notepad++) you'll see that the lines are numbered. The second <gregorian> should be on line 83 or thereabouts. These two tags "wrap" the calendar - everything between them is the stuff that makes the Gregorian calendar, well, the Gregorian calendar.

16. Copy the four first lines of code into a new Notepad++ page (xml version, root version, <calendar>, base static). Now copy everything from <gregorian> to </gregorian) right below those four first lines.

17. Now we replace the word gregorian within both code tags <gregorian> with the name you would like to use for your own calendar. Make sure you write them exactly the same. So instead of having two <gregorian> tags you now write your own name for your calendar. In my case I needed a calendar for my homebrew world, and since the setting employs the calendar of an empire I simply renamed the code tags <Imperial> and </Imperial>. Make sure the second tag keeps the backslash, it tells the program that this is where the info on your calendar ends.

18. Right, now you have a renamed calendar, but it is still the gregorian calendar technically, because as you will see, there's still January, February etc. The process here is simple and really the same as renaming those two tags - you step inside each tag and rename stuff. So instead of <January> you would have, as an example, <Winter's Grip> or whatever.

19. Likewise, you can replace the number of each days in the month with a number more to your liking (instead of January having 31 days, add any other number you would need).

20. Below the tag <lunarweek> you likewise replace the names of the days with something more suitable. Instead of Sunday, I have <Moon's Day>, for example.

21. I am not sure if this step is needed, but I did it and my calendar is working - but I replaced all references to <gregorian> to <Imperial> (in my case), such as in the line <lunardaycalc type="string">gregorian</lundardaycalc> and the corresponding one a little further down the list.

22. Finally, if you wish to add your own special days, you og into the <holidays> section . In the Gregorian calendar you'll see one right away, New Year's Day. We'll use it to build our own special days.

23. If you want to rename New Year to something else, just do the same as we did before. I call it <Day of Winter>. If you need more holidays in the first month, simply copy everything from <holiday1> to </holiday1> and paste it on a new line right below </holiday1>. Rename the "wrapping tags" to <holiday2> and </holiday2>, then rename the day. Replace the number with the number of the day you wish to have this second holiday on.

24. When you wish to add holidays to the other months, copy everything from <holidays> to </holidays> and paste it below the tag <days type = "number">, then replace names and numbers as you see fit.

25. Repeat until you have what you want, then save.

26. You're not quite done yet - you also have to go into the definition.xml file. Here, you add your calendar's name between the <name> tags, your name between the <author> tags, and also define which rulesets can import your calendar (I just left it at <Any>). Save.

27. You should now have a stand-alone file with its own name, e.g. YourNamesCalendar.zip. Rename the zipfile to .mod, and put it back in the correct Fantasy Grounds folder.

28. Start FG, open modules, calendars, and if everything was carefully entered with correct tags et al, you should now see your own calendar as a choice.

I'll add two pictures, one of the original calendars file showing the unmodified Gregorian calendar, and one showing my homebrew calendar. This shows how I simply replaced words and numbers and added holidays to make my own calendar.


20916
20917

Bidmaron
October 7th, 2017, 14:46
Nominate this for sticky.

LordEntrails
October 7th, 2017, 16:04
Stickied or put in a post of resource links (which I don't know if there is one that really fits yet).

adsmalley
April 8th, 2019, 14:24
Is it possible to modify the number of months in a custom calendar (more or less than 12)?

mattekure
April 8th, 2019, 14:38
This is a nice post, thanks for putting it together. You can also take a look at the custom calendar tutorial I put together here https://www.fantasygrounds.com/forums/showthread.php?47885-Fantasy-Grounds-Custom-Calendar-Tutorial It shows how to customize all the elements of a calendar including using extensions to calculate leap years, and making the days of the week flow properly from month to month.

For your reference, in the calendar there are 2 tags which call out and refer to code that is either defined within the corerpg ruleset, or you have to provide it as an extensions.

<lunardaycalc> - the text within this tag is used to point to a lua function that calculates what day of the week a specific date should fall. the gregorian one takes into account all of the little oddities around leap years and such. this is so that if you have Mar 31 land on a tuesday, you want Apr 1 to land on a Wednesday. without this function, FG will have April 1 start on a sunday. Just putting in a name wont make it work unless that function is defined either in the underlying ruleset, or in an extension. All of the calendars in the provided calendar module have their codes defined within the CoreRPG ruleset (and inherited by 5e and others).

<periodvarcalc> the text within this tag is used to determine if there are any leap days to be added to the calendar year. If your calendar has no leap days, you dont need this tag. the gregorian calendar has a function to add the 29 of Feb pre-defined. putting in a name without the function defined will just be ignored.

mattekure
April 8th, 2019, 14:48
Is it possible to modify the number of months in a custom calendar (more or less than 12)?

Yes, you can have any number of months, at least 1.

Thete
April 11th, 2019, 00:37
If I'm using a ruleset created before Core, is there a way of using a calendar with it? I'm lookin g for a Calendar for the WFRP Old Word

mattekure
April 11th, 2019, 00:39
If I'm using a ruleset created before Core, is there a way of using a calendar with it? I'm lookin g for a Calendar for the WFRP Old Word

yes you can, you just have to have any code portion of the calendar be in an extension. The calendar module itself doesnt have to change. So the portsions that would have to be in an extension is the code for any leap years, and code needed to make the days of the week flow correctly. This is the code pointed to by the <lunardaycalc> and <periodvarcalc> tags.

mattekure
April 11th, 2019, 00:42
If I'm using a ruleset created before Core, is there a way of using a calendar with it? I'm lookin g for a Calendar for the WFRP Old Word

Do you have a link to the definition of the calendar you are wanting to use?

Thete
April 11th, 2019, 03:37
I have not created anything files at this stage, I guess I'f be looking at a reference like this https://www.windsofchaos.com/wp-content/uploads/encroachment/calendar-shorthand.pdf

mattekure
April 11th, 2019, 04:45
I have not created anything files at this stage, I guess I'f be looking at a reference like this https://www.windsofchaos.com/wp-content/uploads/encroachment/calendar-shorthand.pdf

Ok, this looks simple enough. let me take a crack at it tomorrow.

Thete
April 11th, 2019, 06:46
Wow, that's very generous. I will play around with the Core calendar so I start to understand what's involved.

mattekure
April 11th, 2019, 13:17
Wow, that's very generous. I will play around with the Core calendar so I start to understand what's involved.

Try these out. when you make the campaign, make sure to select the extension.

Trenloe
April 11th, 2019, 13:24
yes you can, you just have to have any code portion of the calendar be in an extension. The calendar module itself doesnt have to change. So the portsions that would have to be in an extension is the code for any leap years, and code needed to make the days of the week flow correctly. This is the code pointed to by the <lunardaycalc> and <periodvarcalc> tags.
Unfortunately, for rulesets not layered on top of CoreRPG, it's not as simple as this. All of the base calendar code would need to be created in an extension compatible with the ruleset being used. As the CoreRPG calendar functionality is pretty self contained (a sidebar button opens the calendar window and it doesn't interact much with other aspects of FG - other than posting to the chat window) it should be fairly straightforward to take the calendar code in CoreRGP and make an extension compatible with the ruleset being used.

@Thete - which ruleset are you using?

mattekure
April 11th, 2019, 13:43
Doh, I am too used to having all that base code built into CoreRPG. I forgot that if you are not based on it, it could be anything in the ruleset. The one I posted earlier will work for any CoreRPG based ruleset, but obviously it will not likely work for something totally custom.

Thete
April 11th, 2019, 23:56
Try these out. when you make the campaign, make sure to select the extension.

This is very kind of you! I will probably run a core campaign purely as a calendar if I can't get it working with the older ruleset (having an excuse to explore all the additional features in Core is actually v. appealing) :) Also others who use Core for WFRP setting will appreciate this!

Thete
April 11th, 2019, 23:59
Unfortunately, for rulesets not layered on top of CoreRPG, it's not as simple as this. All of the base calendar code would need to be created in an extension compatible with the ruleset being used. As the CoreRPG calendar functionality is pretty self contained (a sidebar button opens the calendar window and it doesn't interact much with other aspects of FG - other than posting to the chat window) it should be fairly straightforward to take the calendar code in CoreRGP and make an extension compatible with the ruleset being used.

@Thete - which ruleset are you using?

That sounds promising! I'm using the neilgfoster's wfrpv3 ruleset.

Trenloe
April 12th, 2019, 12:29
I'm using the neilgfoster's wfrpv3 ruleset.
That doesn’t have the calendar code. Someone would have to write an extension to bring the calendar code and graphics from CoreRPG into the WFRP3 ruleset.

Thete
April 12th, 2019, 12:52
That doesn’t have the calendar code. Someone would have to write an extension to bring the calendar code and graphics from CoreRPG into the WFRP3 ruleset.

I'll put it on my personal todo list (I'm very slow ;) thanks for pointing me in the right direction.

RaviDesai
June 16th, 2020, 03:20
Is it possible to construct a calendar with leap months (such as with the Islamic or Hebrew calendars)? My world has a lunar calendar which has a leap month inserted every other year. Can that be represented in Fantasy Grounds?

Moon Wizard
June 16th, 2020, 08:55
No, the calendar code is fairly simple (as most game system calendars are fairly simple), and was really only modified for the specifics of Gregorian calendar (which is the most common used other than the game system calendars). Anything else would require an extension to rewrite the calendaring system to what you want.

Regards,
JPG

mattekure
June 16th, 2020, 12:54
Is it possible to construct a calendar with leap months (such as with the Islamic or Hebrew calendars)? My world has a lunar calendar which has a leap month inserted every other year. Can that be represented in Fantasy Grounds?

I dont believe its currently possible. The calendar code in CoreRPG defines all months as periods in the xml, and gives access to 2 different functions.

lunardaycalc - This function calculates what day of the week any given date falls on. It is passed a date (year, day, month), and has to return a value between 1 and the number of days in a week.

periodvarcalc - This function is used to implement leap years by calculating how many extra/fewer days are in any given period/month. The function is passed year and month values, and calculates how many extra/fewer days are in that month. For example, February normally has 28 days on any given year. This function would take the values for year and month and calculate that on a leap year, there should be 1 extra day, so it returns the value of 1. Any other month or non-leap year Feb, it would return 0 since there is no change to the period.

There is no function that allows you to insert or remove a period/month from the calendar. This functionality could be developed as an extension, but its not currently possible with the existing code.

Peregrinus Constantine
January 17th, 2023, 14:34
I'm not sure if anyone is checking this thread anymore, but I just wanted to express my thanks to the OP. The instructions were crystal clear, and I was able to create a functional homebrew campaign calendar in Fantasy Grounds by following them.