Module:TarsicanSaros: Difference between revisions

From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs)
Created page with "local p = {} local calendar = require("Module:Calendar") -- Make sure this matches your actual 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", star..."
 
NewZimiaGov (talk | contribs)
No edit summary
Line 1: Line 1:
local p = {}
local p = {}
local calendar = require("Module:Calendar")  -- Make sure this matches your actual calendar module name
local calendar = require("Module:BassaridianCalendar")  -- Make sure this matches your actual calendar module name


-- Constants
-- Constants
Line 63: Line 63:


     -- Pull current date info and events from calendar module
     -- Pull current date info and events from calendar module
     local currentDateString = calendar.getCurrentDate()
     local currentDateString = BassaridianCalendar.getCurrentDate()
     local psscYear = tonumber(string.match(currentDateString, "(%d+)%s+PSSC"))
     local psscYear = tonumber(string.match(currentDateString, "(%d+)%s+PSSC"))
     local events = calendar.events
     local events = BassaridianCalendar.events


     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))

Revision as of 23:15, 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 actual 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 }
}

-- Get season month from day of year
local function getMonth(day)
    if day <= 61 then
        return "Atosiel"
    elseif day <= 122 then
        return "Thalassiel"
    else
        return "Opsitheiel"
    end
end

-- Get zodiac sign from day of year
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

-- Random eclipse subtype (can be customized later)
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

-- MAIN FUNCTION: Generate Eclipse Table
function p.sarosTable(frame)
    local output = {}

    -- Pull current date info and events from calendar module
    local currentDateString = BassaridianCalendar.getCurrentDate()
    local psscYear = tonumber(string.match(currentDateString, "(%d+)%s+PSSC"))
    local events = BassaridianCalendar.events

    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)

        -- Find events within ±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