I've tried to add a custom calendar for a scenario I'm making, but it doesn't update in-game.
Here's the code:
-- Creates a daily calendar to be used in place of the standard monthly/yearly ones
-- Global table containing the calendar
g_DailyCalendar = {};
-- Change these variables to customize the calendar
local iStartYear = 1848; -- Start year
local iStartMonth = 2; -- Month, numerical (1-6)
local iStartDay = 1; -- Day of the month (1)
local iEndYear = 1870; -- Ends September 1
-- Creates a calendar table containing days associated to turns
function PopulateDailyCalendar()
local iLeapDay = 0;
local iTurn = 0;
local MonthName = {"January", "March", "May", "July", "September", "November"};
for iYear = iStartYear, iEndYear, 1 do
if IsLeapYear(iYear) then
iLeapDay = 1;
else
iLeapDay = 0;
end
local iYearStartDay = 1;
local iMonth = 1;
local iMonthDay = 1;
local MonthLength = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
local Month = "Month";
local Day = 0;
local CalendarDay = "CalendarDay";
-- Sets the calendar to start counting at the start date
if iTurn == 0 then
-- Catch any errors in the start date
if iStartMonth > 6 then
iStartMonth = 6;
elseif iStartMonth < 1 then
iStartMonth = 1;
end
if iStartDay > MonthLength[iStartMonth] then
iStartDay = MonthLength[iStartMonth];
elseif iStartDay < 1 then
iStartDay = 1;
end
iMonth = iStartMonth;
iMonthDay = iStartDay;
for i = 1, iStartMonth, 1 do
if i > 1 then
iYearStartDay = iYearStartDay + MonthLength[i - 1];
end
end
iYearStartDay = iYearStartDay + iStartDay - 1;
end
for iDay = iYearStartDay, 6
if iMonthDay < MonthLength[iMonth] then
Day = iMonthDay;
Month = MonthName[iMonth];
iMonthDay = iMonthDay + 1;
else
Day = iMonthDay;
Month = MonthName[iMonth];
iMonthDay = 1;
iMonth = iMonth + 1;
end
CalendarDay = Month .. " " .. Day .. ", " .. iYear;
g_DailyCalendar[iTurn] = CalendarDay;
--print("g_DailyCalendar[" .. iTurn .. "] = " .. g_DailyCalendar[iTurn]);
iTurn = iTurn + 1;
end
end
end
Is there something I'm missing / wrong code? Thanks in advance
Here's the code:
-- Creates a daily calendar to be used in place of the standard monthly/yearly ones
-- Global table containing the calendar
g_DailyCalendar = {};
-- Change these variables to customize the calendar
local iStartYear = 1848; -- Start year
local iStartMonth = 2; -- Month, numerical (1-6)
local iStartDay = 1; -- Day of the month (1)
local iEndYear = 1870; -- Ends September 1
-- Creates a calendar table containing days associated to turns
function PopulateDailyCalendar()
local iLeapDay = 0;
local iTurn = 0;
local MonthName = {"January", "March", "May", "July", "September", "November"};
for iYear = iStartYear, iEndYear, 1 do
if IsLeapYear(iYear) then
iLeapDay = 1;
else
iLeapDay = 0;
end
local iYearStartDay = 1;
local iMonth = 1;
local iMonthDay = 1;
local MonthLength = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
local Month = "Month";
local Day = 0;
local CalendarDay = "CalendarDay";
-- Sets the calendar to start counting at the start date
if iTurn == 0 then
-- Catch any errors in the start date
if iStartMonth > 6 then
iStartMonth = 6;
elseif iStartMonth < 1 then
iStartMonth = 1;
end
if iStartDay > MonthLength[iStartMonth] then
iStartDay = MonthLength[iStartMonth];
elseif iStartDay < 1 then
iStartDay = 1;
end
iMonth = iStartMonth;
iMonthDay = iStartDay;
for i = 1, iStartMonth, 1 do
if i > 1 then
iYearStartDay = iYearStartDay + MonthLength[i - 1];
end
end
iYearStartDay = iYearStartDay + iStartDay - 1;
end
for iDay = iYearStartDay, 6
if iMonthDay < MonthLength[iMonth] then
Day = iMonthDay;
Month = MonthName[iMonth];
iMonthDay = iMonthDay + 1;
else
Day = iMonthDay;
Month = MonthName[iMonth];
iMonthDay = 1;
iMonth = iMonth + 1;
end
CalendarDay = Month .. " " .. Day .. ", " .. iYear;
g_DailyCalendar[iTurn] = CalendarDay;
--print("g_DailyCalendar[" .. iTurn .. "] = " .. g_DailyCalendar[iTurn]);
iTurn = iTurn + 1;
end
end
end
Is there something I'm missing / wrong code? Thanks in advance