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") -- Make sure this matches your module name | ||
-- Constants | -- Constants | ||
| Line 25: | Line 25: | ||
} | } | ||
-- Get | -- Get month based on day | ||
local function getMonth(day) | local function getMonth(day) | ||
if day <= 61 then | if day <= 61 then return "Atosiel" | ||
elseif day <= 122 then return "Thalassiel" | |||
elseif day <= 122 then | else return "Opsitheiel" | ||
else | |||
end | end | ||
end | end | ||
-- Get zodiac | -- Get zodiac based on day | ||
local function getZodiac(day) | local function getZodiac(day) | ||
for _, z in ipairs(zodiacSigns) do | for _, z in ipairs(zodiacSigns) do | ||
| Line 46: | Line 43: | ||
end | end | ||
-- | -- Generate a 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 types = { "Total Solar", "Annular Solar", "Partial Solar" } | ||
return | return types[math.random(#types)] | ||
else | else | ||
local | local types = { "Total Lunar", "Penumbral Lunar", "Partial Lunar" } | ||
return | return types[math.random(#types)] | ||
end | end | ||
end | end | ||
-- MAIN FUNCTION | -- MAIN FUNCTION | ||
function p.sarosTable(frame) | function p.sarosTable(frame) | ||
local output = {} | local output = {} | ||
-- | -- Get date string: e.g. "18, Atosiel (Eosena), 51 PSSC – ..." | ||
local | local dateString = calendar.getCurrentDate() | ||
local psscYear = tonumber(string.match( | local psscYear = tonumber(string.match(dateString, "(%d+)%s+PSSC")) | ||
local events = | local events = calendar.events or {} | ||
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)) | ||
| Line 82: | Line 79: | ||
local zodiac = getZodiac(eclipseDay) | local zodiac = getZodiac(eclipseDay) | ||
-- | -- Look for nearby events ±1 day | ||
local nearbyEvent = "—" | local nearbyEvent = "—" | ||
for offset = -1, 1 do | for offset = -1, 1 do | ||
Revision as of 23:19, 31 May 2025
Documentation for this module may be created at Module:TarsicanSaros/doc
local p = {}
local calendar = require("Module:BassaridianCalendar") -- Make sure this matches your 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 }
}
-- Get month based on day
local function getMonth(day)
if day <= 61 then return "Atosiel"
elseif day <= 122 then return "Thalassiel"
else return "Opsitheiel"
end
end
-- Get zodiac based on day
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 a random eclipse subtype
local function getEclipseSubtype(eclipseType)
math.randomseed(os.time())
if eclipseType == "Solar" then
local types = { "Total Solar", "Annular Solar", "Partial Solar" }
return types[math.random(#types)]
else
local types = { "Total Lunar", "Penumbral Lunar", "Partial Lunar" }
return types[math.random(#types)]
end
end
-- MAIN FUNCTION
function p.sarosTable(frame)
local output = {}
-- Get date string: e.g. "18, Atosiel (Eosena), 51 PSSC – ..."
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" style="width:100%; text-align:center;"')
table.insert(output, '|-\n! Eclipse # !! Day !! Month !! Zodiac Sign !! 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 for nearby events ±1 day
local nearbyEvent = "—"
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
nearbyEvent = events[key]
break
end
end
end
table.insert(output, string.format('|-\n| %d || %d || %s || %s || %s || %s',
i, eclipseDay, month, zodiac, subtype, nearbyEvent
))
eclipseDay = math.floor(eclipseDay + synodicPeriod + ((-1)^i) * 2.3)
isSolar = not isSolar
end
table.insert(output, '|}')
return table.concat(output, "\n")
end
return p