-
October 5th, 2020, 18:59 #51
- Join Date
- Apr 2020
- Posts
- 105
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
-
October 5th, 2020, 19:01 #52
- Join Date
- Apr 2020
- Posts
- 105
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!
-
October 5th, 2020, 19:26 #53
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.
Code: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
For support with any of my extensions, visit my #mattekure-stuff channel on Rob2e's discord https://discord.gg/rob2e
-
October 7th, 2020, 05:02 #54
- Join Date
- Apr 2020
- Posts
- 105
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;
-
October 8th, 2020, 21:11 #55
Hello. Is there a way to insert information for the players or for the GM in the module? Where?
- - -
FG Classic / FG Unity Ultimate
Playing D&D 5th
-
October 8th, 2020, 22:00 #56
- Join Date
- Apr 2020
- Posts
- 105
-
October 8th, 2020, 22:15 #57
Problems? See; How to Report Issues, Bugs & Problems
On Licensing & Distributing Community Content
Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
Note, I am not a SmiteWorks employee or representative, I'm just a user like you.
-
October 8th, 2020, 22:35 #58
Also Player Agency will allow players to record info into any date the GM has initiated.
-
October 9th, 2020, 01:55 #59
Yeah, I'm seeing
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.
Calendar.png
I want to add information in the red rectangle direct from the module.- - -
FG Classic / FG Unity Ultimate
Playing D&D 5th
-
October 9th, 2020, 02:07 #60
- Join Date
- Apr 2020
- Posts
- 105
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.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks