PDA

View Full Version : Custom Calendar - help with lunardaycalc



JShadow007
February 11th, 2017, 04:39
Howdy folks!

New to FG and still learning the ropes, but I feel like I've searched every single calendar thread on the forums and can't quite find the answer I'm looking for.

In short: the Gregorian calendar lunardaycalc option makes a calendar work nicely with Monday the 31st coming before Tuesday the 1st of the next month etc. How do I do this with a non-Gregorian calendar?

My campaign's custom calendar has 12 months of 30 days each, with five days' worth of holidays spread between the months. Each week has only 7 days. How do I make the dates sync up properly to the week days?



<Collapse>
<name type="string">Calendar of Avarus</name>
<setting type="string">Collapse</setting>
<lunarweek>
<day1 type="string">Saulesday</day1>
<day2 type="string">Selensday</day2>
<day3 type="string">Tyrsday</day3>
<day4 type="string">Crownsday</day4>
<day5 type="string">Geldursday</day5>
<day6 type="string">Daliasday</day6>
<day7 type="string">Ausrinesday</day7>
</lunarweek>
<periods>
<period1>
<days type="number">30</days>
<name type="string">Kyzer</name>
</period1>
<period10>
<days type="number">30</days>
<name type="string">Tavalas</name>
</period10>
<period11>
<days type="number">30</days>
<holidays>
<holiday1>
<duration type="number">1</duration>
<name type="string">Autumn Equinox</name>
<startday type="number">21</startday>
</holiday1>
</holidays>
<name type="string">Selene</name>
</period11>
<period12>
<days type="number">30</days>
<name type="string">Zauberyn</name>
</period12>
<period13>
<days type="number">30</days>
<name type="string">Therran</name>
</period13>
<period14>
<days type="number">30</days>
<holidays>
<holiday1>
<duration type="number">1</duration>
<name type="string">Winter Solstice</name>
<startday type="number">21</startday>
</holiday1>
</holidays>
<name type="string">Morpheus</name>
</period14>
<period15>
<days type="number">1</days>
<name type="string">The Dreaming</name>
</period15>
<period2>
<days type="number">30</days>
<name type="string">Noxan</name>
</period2>
<period3>
<days type="number">30</days>
<holidays>
<holiday1>
<duration type="number">1</duration>
<name type="string">Spring Equinox</name>
<startday type="number">21</startday>
</holiday1>
</holidays>
<name type="string">Kovas</name>
</period3>
<period4>
<days type="number">1</days>
<holidays>
<holiday1>
<duration type="number">1</duration>
<name type="string">Rebirth</name>
<startday type="number">1</startday>
</holiday1>
</holidays>
<name type="string">Rebirth</name>
</period4>
<period5>
<days type="number">30</days>
<name type="string">Epsion</name>
</period5>
<period6>
<days type="number">30</days>
<name type="string">Amorien</name>
</period6>
<period7>
<days type="number">30</days>
<holidays>
<holiday1>
<duration type="number">1</duration>
<name type="string">Summer Solstice</name>
<startday type="number">21</startday>
</holiday1>
</holidays>
<name type="string">Saule</name>
</period7>
<period8>
<days type="number">3</days>
<holidays>
<holiday1>
<duration type="number">3</duration>
<name type="string">Midsummer Annual Holiday</name>
<startday type="number">1</startday>
</holiday1>
<holiday2>
<duration type="number">1</duration>
<name type="string">Leap Year - Every Four Years</name>
<startday type="number">1</startday>
</holiday2>
</holidays>
<name type="string">Midsummer</name>
</period8>
<period9>
<days type="number">30</days>
<name type="string">Ausrine</name>
</period9>
</periods>
</Collapse>


Bonus points: is there a way to make my 3 day midsummer holiday *4* days long during a leap year?

Many thanks!!!

Andraax
February 11th, 2017, 13:39
Try the attached extension & module:

JShadow007
February 11th, 2017, 17:15
This was perfect!!! Thank you so much :)

I never would've figured out the coding for the extension. Maybe now if I stare at it long enough I can reproduce it and tweak it if I need to make a new calendar for another game.

(or I'll just make months of even length ;) )

Andraax
February 11th, 2017, 17:40
It doesn't handle missing leap years - it just assumes every fourth year is a leap year (which is what eventually led to the Gregorian Calendar Reform, the extra leap years made the calendar slowly move forward through the seasons). You didn't give enough details to do anything else.

JShadow007
February 11th, 2017, 17:42
Oh, no, I do not need realism here beyond the weekdays syncing up. This is perfect. You see, magic guarantees that the leap year fixes the calendar for eternity. (Screw you, astrophysics! ;) )

Thanks again :)

mprigge
May 2nd, 2018, 05:45
Try the attached extension & module:

This was super helpful in figuring out my own custom calendar for Matt Mercer's Tal'Dorei campaign setting (which is goofy as it has variable length months). Never even touched LUA before, but this was a good enough example to figure it out. Just wanted to say thanks!

Andraax
May 2nd, 2018, 12:55
This was super helpful in figuring out my own custom calendar for Matt Mercer's Tal'Dorei campaign setting (which is goofy as it has variable length months). Never even touched LUA before, but this was a good enough example to figure it out. Just wanted to say thanks!

I had already done an extension for the Tal'Dorei setting...

mprigge
May 2nd, 2018, 14:25
I had already done an extension for the Tal'Dorei setting...

Oh. Well that sorta sucks. It was a useful learning exercise as I've never used LUA much less tried to create an extension for FG, but still sucks to cross the same ground someone else has crossed.

Note to self: use google to search FG, not FG to search FG. :-)

Andraax
May 2nd, 2018, 15:11
You can always compare code; I do that occasionally to improve my own.

mprigge
May 2nd, 2018, 15:31
You can always compare code; I do that occasionally to improve my own.

I already did and it was very helpful! Your LUA is far more compact - you can definitely tell I was learning as I was going. However, the lunar day calc is "wrong" in the sense that you were given the wrong date reference in that thread. There's a whole thread on reddit trying to establish the timeline of CR's first campaign that goes into that in depth, but a "canon" date is Conthsen, 24 Duscar 811 PD which isn't what you were given. But aside from that, yours is far better. :-)

Andraax
May 2nd, 2018, 16:16
Here is an update.

LordEntrails
May 2nd, 2018, 16:55
Note to self: use google to search FG, not FG to search FG. :-)
Yea, the forum search is... well, the forum search. If you use the Site Search from the top menu, it's a custom Google search and is much better than the forum search.

mprigge
May 2nd, 2018, 16:58
Yea, the forum search is... well, the forum search. If you use the Site Search from the top menu, it's a custom Google search and is much better than the forum search.

This is a super, super noob question: Is there a well-maintained list of Extensions / Modules somewhere? Seems like there's a lot of really awesome content lurking as forum attachments that lots of people may not know exists.

LordEntrails
May 2nd, 2018, 17:02
This is a super, super noob question: Is there a well-maintained list of Extensions / Modules somewhere? Seems like there's a lot of really awesome content lurking as forum attachments that lots of people may not know exists.
Yes, but probably not perfectly maintained.
Start with the CoreRPG list of extensions (https://www.fantasygrounds.com/forums/showthread.php?20320-CoreRPG-Community-Extensions). Since most rulesets are children of CoreRPG, these extensions work for most rulesets.

Then most ruleset specific forums (like 5E has this one (https://www.fantasygrounds.com/forums/showthread.php?27298-Extensions-Modules-Pregens-and-other-5E-resources)) have a sticky thread with resources or extensions that only work in that ruleset.

mprigge
May 2nd, 2018, 17:16
Yes, but probably not perfectly maintained.
Start with the CoreRPG list of extensions (https://www.fantasygrounds.com/forums/showthread.php?20320-CoreRPG-Community-Extensions). Since most rulesets are children of CoreRPG, these extensions work for most rulesets.

Then most ruleset specific forums (like 5E has this one (https://www.fantasygrounds.com/forums/showthread.php?27298-Extensions-Modules-Pregens-and-other-5E-resources)) have a sticky thread with resources or extensions that only work in that ruleset.

Hmm. Seems like a problem sort of begging for a solution?

I am very new to this community, so this may be the ultimate in hubris to even suggest, but if there were a web-based repo where you could upload community extension/modules and it'd parse their metadata and make them available for search/download, would that be useful? Ultimately, I suppose you could also leverage that to end up with an app that'd handle selecting, installing, and updating extensions/mods, also. But at least making it easy to find the stuff people have worked hard to create?

Or maybe it's totally fine as is. Just seems non-intuitive to a newb, but I should probably also lurk more. :D

LordEntrails
May 2nd, 2018, 20:26
Hmm. Seems like a problem sort of begging for a solution?

I am very new to this community, so this may be the ultimate in hubris to even suggest, but if there were a web-based repo where you could upload community extension/modules and it'd parse their metadata and make them available for search/download, would that be useful? Ultimately, I suppose you could also leverage that to end up with an app that'd handle selecting, installing, and updating extensions/mods, also. But at least making it easy to find the stuff people have worked hard to create?

Or maybe it's totally fine as is. Just seems non-intuitive to a newb, but I should probably also lurk more. :D
No, not hubris. And this has been discussed before.

I can't say I am or was completely involved in the discussion or aware of the pros and cons, but I can say one concern is security. Such a repository would have to be a trusted source. And who would manage that? That would be a lot of liability for SmiteWorks to take on. And of course doing so through the community raises questions too.

But, that's not to say it's impossible. I will say such a discussion would probably be best in a new thread since as you can imagine, it might go on for awhile :)

Chicken Denchers
July 8th, 2018, 21:05
Hello all! I decided to join this thread rather than start a new one since my issue is exactly the same as OP's. I made a calendar like follows (no leap years) but can't get the weekdays to line up from month to month (it always wants to start on Sunday). Here's the bit I wrote copying the gregorian style calendar (I left in the lunardaycalc type and periodvarcalc type for this post even though it's wrong since I know that's where I'll reference the extension):


<fjellvale>
<name type="string">Fjellvale Calendar</name>
<setting type="string">Any</setting>
<lunardaycalc type="string">gregorian</lunardaycalc>
<lunarweek>
<day1 type="string">Sunday</day1>
<day2 type="string">Moonday</day2>
<day3 type="string">Oathday</day3>
<day4 type="string">Godday</day4>
<day5 type="string">Freeday</day5>
<day6 type="string">Starday</day6>
</lunarweek>
<periodvarcalc type="string">gregorian</periodvarcalc>
<periods>
<period1>
<days type="number">60</days>
<holidays>
<holiday1>
<duration type="number">2</duration>
<name type="string">The Dawning</name>
<startday type="number">1</startday>
</holiday1>
<holiday2>
<duration type="number">1</duration>
<name type="string">Deep Winter ends</name>
<startday type="number">30</startday>
</holiday2>
<holiday3>
<duration type="number">1</duration>
<name type="string">End Winter begins</name>
<startday type="number">31</startday>
</holiday3>
<holiday4>
<duration type="number">1</duration>
<name type="string">Day of the Ancients</name>
<startday type="number">37</startday>
</holiday4>
<holiday5>
<duration type="number">1</duration>
<name type="string">End Winter ends</name>
<startday type="number">60</startday>
</holiday5>
</holidays>
<name type="string">Armaned</name>
</period1>
<period2>
<days type="number">56</days>
<holidays>
<holiday1>
<duration type="number">1</duration>
<name type="string">Spring begins</name>
<startday type="number">1</startday>
</holiday1>
<holiday2>
<duration type="number">6</duration>
<name type="string">Snowflowers</name>
<startday type="number">6</startday>
</holiday2>
<holiday3>
<duration type="number">4</duration>
<name type="string">New Garden</name>
<startday type="number">36</startday>
</holiday3>
<holiday4>
<duration type="number">1</duration>
<name type="string">Spring ends</name>
<startday type="number">56</startday>
</holiday4>
</holidays>
<name type="string">Velmaned</name>
</period2>
<period3>
<days type="number">60</days>
<holidays>
<holiday1>
<duration type="number">1</duration>
<name type="string">Low Summer begins</name>
<startday type="number">1</startday>
</holiday1>
<holiday2>
<duration type="number">1</duration>
<name type="string">Day of Lordship</name>
<startday type="number">4</startday>
</holiday2>
<holiday3>
<duration type="number">1</duration>
<name type="string">Day of Kingship</name>
<startday type="number">7</startday>
</holiday3>
<holiday3>
<duration type="number">1</duration>
<name type="string">Low Summer ends</name>
<startday type="number">30</startday>
</holiday3>
<holiday4>
<duration type="number">1</duration>
<name type="string">High Summer begins</name>
<startday type="number">31</startday>
</holiday4>
<holiday5>
<duration type="number">1</duration>
<name type="string">Day of Sovereignty</name>
<startday type="number">37</startday>
</holiday5>
</holidays>
<name type="string">Erkausi</name>
</period3>
<period4>
<days type="number">60</days>
<holidays>
<holiday1>
<duration type="number">6</duration>
<name type="string">Richfest/Highsun</name>
<startday type="number">4</startday>
</holiday1>
<holiday2>
<duration type="number">1</duration>
<name type="string">High Summer ends</name>
<startday type="number">30</startday>
</holiday2>
<holiday3>
<duration type="number">1</duration>
<name type="string">End Summer begins</name>
<startday type="number">31</startday>
</holiday3>
<holiday4>
<duration type="number">1</duration>
<name type="string">End Summer ends</name>
<startday type="number">60</startday>
</holiday4>
</holidays>
<name type="string">Almonat</name>
</period4>
<period5>
<days type="number">56</days>
<holidays>
<holiday1>
<duration type="number">1</duration>
<name type="string">Autumn begins</name>
<startday type="number">1</startday>
</holiday1>
<holiday2>
<duration type="number">6</duration>
<name type="string">Brewfest</name>
<startday type="number">39</startday>
</holiday2>
<holiday3>
<duration type="number">3</duration>
<name type="string">Nightcreep</name>
<startday type="number">53</startday>
</holiday3>
<holiday4>
<duration type="number">1</duration>
<name type="string">Autumn ends</name>
<startday type="number">56</startday>
</holiday4>
</holidays>
<name type="string">Jermanad</name>
</period5>
<period6>
<days type="number">60</days>
<holidays>
<holiday1>
<duration type="number">1</duration>
<name type="string">Low Winter begins</name>
<startday type="number">1</startday>
</holiday1>
<holiday2>
<duration type="number">6</duration>
<name type="string">Harvest Festival</name>
<startday type="number">3</startday>
</holiday2>
<holiday3>
<duration type="number">1</duration>
<name type="string">Day of Plenty</name>
<startday type="number">11</startday>
</holiday3>
<holiday4>
<duration type="number">1</duration>
<name type="string">Low Winter ends</name>
<startday type="number">30</startday>
</holiday4>
<holiday5>
<duration type="number">1</duration>
<name type="string">Deep Winter begins</name>
<startday type="number">31</startday>
</holiday5>
<holiday6>
<duration type="number">16</duration>
<name type="string">The Dawning</name>
<startday type="number">45</startday>
</holiday6>
</holidays>
<name type="string">Jofunde</name>
</period6>
</periods>
</fjellvale>

Any help with creating the requisite extension would be greatly appreciated!

In case it isn't clear, there are 6 weekdays, 6 months, 4 months have 60 days but 2 months have 56 days (the second and fifth months), and the year has 352 days in it total.

Andraax
July 8th, 2018, 21:10
Well, you're telling it to use Gregorian calendar calculations with a non-Gregorian calendar. You'll need to write your own "lunardaycalc" and "periodvarcalc" functions and register them via an extension.

Chicken Denchers
July 9th, 2018, 17:01
Yes, that's the bit I'm asking for help with. I noted in the post that I knew that part was incorrect but left it in since I know that's where the extension reference will go.

Chicken Denchers
July 9th, 2018, 17:14
Here's what I have so far from the copied "collapse calendar" lua file at the beginning of this thread, but I'm both not a programmer and not a math guy (also I don't know lua) so I don't know where to go from the few things I've edited here:


--
-- Please see the license.html file included with this distribution for
-- attribution and copyright information.
--

function onInit()
CalendarManager.registerLunarDayHandler("fjellvale", calcFjellvaleLunarDay);
CalendarManager.registerMonthVarHandler("collapse", calcFjellvaleMonthVar);
end

function calcFjellvaleLunarDay(nYear, nMonth, nDay)
local nZYear = nYear - 1;
local nZYearDays = nZYear * 352 + math.floor(nZYear / 4);
local rDay = nDay + (nMonth-1)*30;
if nMonth > 4 then
rDay = rDay - 29;
end
if nMonth > 8 then
rDay = rDay - 27;
if (nYear % 4) == 0 then
rDay = rDay + 1;
end
end
rDay = (nZYearDays + rDay) % 7;
if rDay == 0 then
return 7;
end
return rDay;
end

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

return 0;
end

Andraax
July 9th, 2018, 19:05
Well, first, there are no leap years, so you don't need "periodvarcalc" nor do you need to call CalendarManager.registerMonthVarHandler (those are to handle months that have variable lengths).

Second, you need to know at least one fixed date with a year to calculate dates from. So, I need to know what day of week on a particular year the 1st of Armaned falls on.

Chicken Denchers
July 10th, 2018, 17:35
In the year 1101 it starts on Oathday (the third day of the week), but I'm willing to change that to any day of the week if that's easier. Anything else important to know?

And thanks for helping me out by the way! I really appreciate it.

Andraax
July 10th, 2018, 18:49
Give these a try.

Chicken Denchers
July 11th, 2018, 16:28
Seems to be working great! Thank you so much!