Module:GeneralPortStorage: Difference between revisions
From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs) Created page with "-- Module:GeneralPortStorageLog local p = {} local function getCurrentDate() local startDate = os.time({year = 1999, month = 8, day = 6}) local currentDate = os.time() local daysPerYear = 183 local totalDaysElapsed = math.floor((currentDate - startDate) / 86400) local year = math.floor(totalDaysElapsed / daysPerYear) local day = (totalDaysElapsed % daysPerYear) + 1 return year, day end local function clamp(val, min, max) if val < min the..." |
NewZimiaGov (talk | contribs) No edit summary |
||
| Line 4: | Line 4: | ||
local function getCurrentDate() | local function getCurrentDate() | ||
local startDate = os.time({year = 1999, month = 8, day = 6}) | local startDate = os.time({year = 1999, month = 8, day = 6}) | ||
local secondsInDay = 86400 | |||
local daysPerYear = 183 | |||
local currentDate = os.time() | local currentDate = os.time() | ||
local totalDaysElapsed = math.floor((currentDate - startDate) / secondsInDay) | |||
local totalDaysElapsed = math.floor((currentDate - startDate) / | |||
local | local yearFraction = totalDaysElapsed / daysPerYear | ||
local | local psscYear = math.floor(yearFraction) | ||
local dayOfYear = math.floor((yearFraction - psscYear) * daysPerYear) + 1 | |||
return psscYear, dayOfYear | |||
end | end | ||
Latest revision as of 22:43, 23 April 2025
Documentation for this module may be created at Module:GeneralPortStorage/doc
-- Module:GeneralPortStorageLog
local p = {}
local function getCurrentDate()
local startDate = os.time({year = 1999, month = 8, day = 6})
local secondsInDay = 86400
local daysPerYear = 183
local currentDate = os.time()
local totalDaysElapsed = math.floor((currentDate - startDate) / secondsInDay)
local yearFraction = totalDaysElapsed / daysPerYear
local psscYear = math.floor(yearFraction)
local dayOfYear = math.floor((yearFraction - psscYear) * daysPerYear) + 1
return psscYear, dayOfYear
end
function p.generateStorageLog()
local year, day = getCurrentDate()
local dateStr = string.format("Day %d, Y.%d", day, year)
local dryCapacity = 6500000 -- m³
local coldCapacity = 1800000 -- m³
local liquidCapacity = 800000 -- m³
local yardCapacity = 3200000 -- TEU
local dryStored = math.random(4000000, 6900000)
local coldStored = math.random(1000000, 1900000)
local liquidStored = math.random(500000, 850000)
local yardUsage = math.random(2500000, 3400000)
local dryConsumed = math.random(100000, 300000)
local coldConsumed = math.random(80000, 200000)
local liquidConsumed = math.random(40000, 120000)
local dryDispatched = math.random(100000, 250000)
local coldDispatched = math.random(60000, 180000)
local liquidDispatched = math.random(30000, 100000)
local overflowFlag = yardUsage > yardCapacity and "Yes – Overflow protocols active" or "No – Operating within limits"
local log = "{| class=\"wikitable\" style=\"width:100%\"\n"
log = log .. string.format("! colspan=2 | General Port of Lake Morovia – Storage Logistics Log (%s)\n", dateStr)
log = log .. "|-\n"
log = log .. string.format("| '''Dry Storage Inventory''' || %d m³\n", dryStored)
log = log .. "|-\n"
log = log .. string.format("| '''Refrigerated Storage Inventory''' || %d m³\n", coldStored)
log = log .. "|-\n"
log = log .. string.format("| '''Liquid Bulk Storage Inventory''' || %d m³\n", liquidStored)
log = log .. "|-\n"
log = log .. string.format("| '''Container Yard Usage''' || %d TEU\n", yardUsage)
log = log .. "|-\n"
log = log .. string.format("| '''Container Yard Overflow''' || %s\n", overflowFlag)
log = log .. "|-\n"
log = log .. string.format("| '''Dry Goods Consumed''' || %d m³\n", dryConsumed)
log = log .. "|-\n"
log = log .. string.format("| '''Refrigerated Goods Consumed''' || %d m³\n", coldConsumed)
log = log .. "|-\n"
log = log .. string.format("| '''Liquid Bulk Consumed''' || %d m³\n", liquidConsumed)
log = log .. "|-\n"
log = log .. string.format("| '''Dry Goods Dispatched''' || %d m³\n", dryDispatched)
log = log .. "|-\n"
log = log .. string.format("| '''Refrigerated Goods Dispatched''' || %d m³\n", coldDispatched)
log = log .. "|-\n"
log = log .. string.format("| '''Liquid Bulk Dispatched''' || %d m³\n", liquidDispatched)
log = log .. "|}"
return log
end
function p.dailyStorageSummary()
local year, day = getCurrentDate()
local header = string.format("'''General Port of Lake Morovia: Storage Log – Day %d, Year %d PSSC'''\n", day, year)
return header .. p.generateStorageLog()
end
return p