Module:TarsicanSaros: Difference between revisions
From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs) No edit summary |
NewZimiaGov (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local calendar = require("Module:BassaridianCalendar") -- | local calendar = require("Module:BassaridianCalendar") -- Ensure this matches your calendar module name | ||
-- Constants | -- Constants | ||
| Line 25: | Line 25: | ||
} | } | ||
-- | -- Determine season/month | ||
local function getMonth(day) | local function getMonth(day) | ||
if day <= 61 then return "Atosiel" | if day <= 61 then return "Atosiel" | ||
| Line 33: | Line 33: | ||
end | end | ||
-- | -- Determine zodiac sign | ||
local function getZodiac(day) | local function getZodiac(day) | ||
for _, z in ipairs(zodiacSigns) do | for _, z in ipairs(zodiacSigns) do | ||
| Line 43: | Line 43: | ||
end | end | ||
-- Generate | -- Generate random eclipse subtype | ||
local function getEclipseSubtype(eclipseType) | local function getEclipseSubtype(eclipseType) | ||
math.randomseed(os.time()) | math.randomseed(os.time()) | ||
if eclipseType == "Solar" then | if eclipseType == "Solar" then | ||
local | local options = { "Total Solar", "Annular Solar", "Partial Solar" } | ||
return | return options[math.random(#options)] | ||
else | else | ||
local | local options = { "Total Lunar", "Penumbral Lunar", "Partial Lunar" } | ||
return | return options[math.random(#options)] | ||
end | end | ||
end | end | ||
-- MAIN FUNCTION | -- Format event entry | ||
local function formatEvent(event) | |||
if event.link and event.name then | |||
return string.format("[%s %s]<br><small>''%s''</small>", event.link, event.name, event.city or "") | |||
elseif event.name then | |||
return string.format("'''%s'''", event.name) | |||
else | |||
return "—" | |||
end | |||
end | |||
-- MAIN TABLE FUNCTION | |||
function p.sarosTable(frame) | function p.sarosTable(frame) | ||
local output = {} | local output = {} | ||
-- Get | -- Get year and events from calendar module | ||
local dateString = calendar.getCurrentDate() | local dateString = calendar.getCurrentDate() | ||
local psscYear = tonumber(string.match(dateString, "(%d+)%s+PSSC")) | local psscYear = tonumber(string.match(dateString, "(%d+)%s+PSSC")) | ||
| Line 65: | Line 76: | ||
table.insert(output, string.format("== Tarsican Eclipse Schedule – Year %d PSSC ==\n", psscYear)) | table.insert(output, string.format("== Tarsican Eclipse Schedule – Year %d PSSC ==\n", psscYear)) | ||
table.insert(output, '{| class="wikitable" style="width:100%; text-align:center;"') | table.insert(output, '{| class="wikitable sortable" style="width:100%; text-align:center;"') | ||
table.insert(output, '|-\n! | table.insert(output, '|-\n! # !! Day !! Month !! Zodiac !! Eclipse Type !! Nearby Ritual or Holiday') | ||
local eclipseDay = 18 | local eclipseDay = 18 | ||
| Line 79: | Line 90: | ||
local zodiac = getZodiac(eclipseDay) | local zodiac = getZodiac(eclipseDay) | ||
-- Look for nearby | -- Look ±1 day for a nearby holiday | ||
local | local holidayOutput = "—" | ||
for offset = -1, 1 do | for offset = -1, 1 do | ||
local checkDay = eclipseDay + offset | local checkDay = eclipseDay + offset | ||
| Line 91: | Line 102: | ||
dayInMonth = checkDay - 122 | dayInMonth = checkDay - 122 | ||
end | end | ||
local key = checkMonth .. "," .. dayInMonth | local key = checkMonth .. "," .. dayInMonth | ||
if events[key] then | if events[key] then | ||
holidayOutput = formatEvent(events[key]) | |||
break | break | ||
end | end | ||
| Line 100: | Line 110: | ||
end | end | ||
table.insert(output, string.format('|-\n| %d || %d || %s || %s || %s || %s', | table.insert(output, string.format( | ||
i, eclipseDay, month, zodiac, subtype, | '|-\n| %d || %d || %s || %s || %s || %s', | ||
i, eclipseDay, month, zodiac, subtype, holidayOutput | |||
)) | )) | ||
Revision as of 23:24, 31 May 2025
Documentation for this module may be created at Module:TarsicanSaros/doc
local p = {}
local calendar = require("Module:BassaridianCalendar") -- Ensure this matches your calendar module name
-- Constants
local synodicPeriod = 24.8
local micrasYearLength = 183
-- Zodiac definitions
local zodiacSigns = {
{ name = "Atosien", start = 1, stop = 12 },
{ name = "Eosena", start = 13, stop = 24 },
{ name = "Micrasha", start = 25, stop = 36 },
{ name = "Pyreska", start = 37, stop = 48 },
{ name = "Indomin", start = 49, stop = 61 },
{ name = "Chrysen", start = 62, stop = 73 },
{ name = "Thalassian", start = 74, stop = 85 },
{ name = "Nephelia", start = 86, stop = 97 },
{ name = "Glinaeus", start = 98, stop = 109 },
{ name = "Noctien", start = 110, stop = 122 },
{ name = "Opsithia", start = 123, stop = 133 },
{ name = "Stygian", start = 134, stop = 145 },
{ name = "Faunian", start = 146, stop = 157 },
{ name = "Silenian", start = 158, stop = 169 },
{ name = "Catosien", start = 170, stop = 183 }
}
-- Determine season/month
local function getMonth(day)
if day <= 61 then return "Atosiel"
elseif day <= 122 then return "Thalassiel"
else return "Opsitheiel"
end
end
-- Determine zodiac sign
local function getZodiac(day)
for _, z in ipairs(zodiacSigns) do
if day >= z.start and day <= z.stop then
return z.name
end
end
return "Unknown"
end
-- Generate random eclipse subtype
local function getEclipseSubtype(eclipseType)
math.randomseed(os.time())
if eclipseType == "Solar" then
local options = { "Total Solar", "Annular Solar", "Partial Solar" }
return options[math.random(#options)]
else
local options = { "Total Lunar", "Penumbral Lunar", "Partial Lunar" }
return options[math.random(#options)]
end
end
-- Format event entry
local function formatEvent(event)
if event.link and event.name then
return string.format("[%s %s]<br><small>''%s''</small>", event.link, event.name, event.city or "")
elseif event.name then
return string.format("'''%s'''", event.name)
else
return "—"
end
end
-- MAIN TABLE FUNCTION
function p.sarosTable(frame)
local output = {}
-- Get year and events from calendar module
local dateString = calendar.getCurrentDate()
local psscYear = tonumber(string.match(dateString, "(%d+)%s+PSSC"))
local events = calendar.events or {}
table.insert(output, string.format("== Tarsican Eclipse Schedule – Year %d PSSC ==\n", psscYear))
table.insert(output, '{| class="wikitable sortable" style="width:100%; text-align:center;"')
table.insert(output, '|-\n! # !! Day !! Month !! Zodiac !! Eclipse Type !! Nearby Ritual or Holiday')
local eclipseDay = 18
local isSolar = true
for i = 1, 10 do
if eclipseDay > micrasYearLength then break end
local eclipseType = isSolar and "Solar" or "Lunar"
local subtype = getEclipseSubtype(eclipseType)
local month = getMonth(eclipseDay)
local zodiac = getZodiac(eclipseDay)
-- Look ±1 day for a nearby holiday
local holidayOutput = "—"
for offset = -1, 1 do
local checkDay = eclipseDay + offset
if checkDay >= 1 and checkDay <= micrasYearLength then
local checkMonth = getMonth(checkDay)
local dayInMonth = checkDay
if checkMonth == "Thalassiel" then
dayInMonth = checkDay - 61
elseif checkMonth == "Opsitheiel" then
dayInMonth = checkDay - 122
end
local key = checkMonth .. "," .. dayInMonth
if events[key] then
holidayOutput = formatEvent(events[key])
break
end
end
end
table.insert(output, string.format(
'|-\n| %d || %d || %s || %s || %s || %s',
i, eclipseDay, month, zodiac, subtype, holidayOutput
))
eclipseDay = math.floor(eclipseDay + synodicPeriod + ((-1)^i) * 2.3)
isSolar = not isSolar
end
table.insert(output, '|}')
return table.concat(output, "\n")
end
return p