Module:AutoUpdateAgPrices: 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 = {} | ||
-- Function to safely get the current date | |||
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}) | ||
| Line 28: | Line 29: | ||
end | end | ||
-- Product data | |||
local products = { | local products = { | ||
{"Rice", "Gladeseed Farmers' Union", 9.00}, | {"Rice", "Gladeseed Farmers' Union", 9.00}, | ||
| Line 38: | Line 40: | ||
{"Processed Noctic Rabrev Flower", "Noctic Fleet", 2.50}, | {"Processed Noctic Rabrev Flower", "Noctic Fleet", 2.50}, | ||
{"Noctic-Rabrev Flower Concentrate", "Noctic Fleet", 3.00}, | {"Noctic-Rabrev Flower Concentrate", "Noctic Fleet", 3.00}, | ||
{"Manwine", "Jogiani Merchants of Manwine", 2.07}, | {"Manwine", "Jogiani Merchants of Manwine", 2.07}, | ||
{"Milkwine", "Jogiani Merchants of Manwine", 6.00}, | {"Milkwine", "Jogiani Merchants of Manwine", 6.00}, | ||
{"Wheat", "Plains of Jogi", 0.30}, | {"Wheat", "Plains of Jogi", 0.30}, | ||
{"Oats", "Plains of Jogi", 0.23}, | {"Oats", "Plains of Jogi", 0.23}, | ||
| Line 52: | Line 47: | ||
{"Hay", "Plains of Jogi", 0.45}, | {"Hay", "Plains of Jogi", 0.45}, | ||
{"Ale of the Night", "Ale of the Night Central Brewery", 2.43}, | {"Ale of the Night", "Ale of the Night Central Brewery", 2.43}, | ||
{"Camel Meat", "Camel Herders of the Jangsong Province", 34.65}, | {"Camel Meat", "Camel Herders of the Jangsong Province", 34.65}, | ||
{"Camel Milk", "Camel Herders of the Jangsong Province", 5.20}, | {"Camel Milk", "Camel Herders of the Jangsong Province", 5.20}, | ||
{"Pearls", "Anterran Imports and Services", 0.79}, | {"Pearls", "Anterran Imports and Services", 0.79}, | ||
{"Abalone", "Anterran Imports and Services", 2.64}, | {"Abalone", "Anterran Imports and Services", 2.64}, | ||
{"Opium", "Merchant Guild of the Poppy Goddess", 0.18}, | {"Opium", "Merchant Guild of the Poppy Goddess", 0.18}, | ||
{"Silk", "Seamstresses of Rouge", 5.00}, | {"Silk", "Seamstresses of Rouge", 5.00}, | ||
{"Horehound Mead", "Salurian Temple of Sacred Horehound", 0.05}, | {"Horehound Mead", "Salurian Temple of Sacred Horehound", 0.05}, | ||
} | } | ||
-- Function to provide products to other modules | |||
function p.get_products() | |||
return products | |||
return | |||
end | end | ||
return p | return p | ||
Revision as of 18:57, 24 December 2024
Documentation for this module may be created at Module:AutoUpdateAgPrices/doc
local p = {}
-- Function to safely get the current date
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
local month, dayOfMonth
if dayOfYear <= 61 then
month = 1
dayOfMonth = dayOfYear
elseif dayOfYear <= 122 then
month = 2
dayOfMonth = dayOfYear - 61
else
month = 3
dayOfMonth = dayOfYear - 122
end
return string.format("%d/%d/%d [[PSSC]]", dayOfMonth, month, psscYear), dayOfMonth, month
end
-- Product data
local products = {
{"Rice", "Gladeseed Farmers' Union", 9.00},
{"Edible Algae", "Gladeseed Farmers' Union", 21.00},
{"Shrimp", "Gladeseed Farmers' Union", 15.00},
{"Anterran Spicy Onion", "Gladeseed Farmers' Union", 18.00},
{"Queen's Garlic", "Gladeseed Farmers' Union", 27.00},
{"Morovian Water Buffalo", "Atterian Cattle Drivers", 6.60},
{"Unprocessed Noctic-Rabrev Flower", "Noctic Fleet", 6.00},
{"Processed Noctic Rabrev Flower", "Noctic Fleet", 2.50},
{"Noctic-Rabrev Flower Concentrate", "Noctic Fleet", 3.00},
{"Manwine", "Jogiani Merchants of Manwine", 2.07},
{"Milkwine", "Jogiani Merchants of Manwine", 6.00},
{"Wheat", "Plains of Jogi", 0.30},
{"Oats", "Plains of Jogi", 0.23},
{"Cereal", "Plains of Jogi", 0.52},
{"Hay", "Plains of Jogi", 0.45},
{"Ale of the Night", "Ale of the Night Central Brewery", 2.43},
{"Camel Meat", "Camel Herders of the Jangsong Province", 34.65},
{"Camel Milk", "Camel Herders of the Jangsong Province", 5.20},
{"Pearls", "Anterran Imports and Services", 0.79},
{"Abalone", "Anterran Imports and Services", 2.64},
{"Opium", "Merchant Guild of the Poppy Goddess", 0.18},
{"Silk", "Seamstresses of Rouge", 5.00},
{"Horehound Mead", "Salurian Temple of Sacred Horehound", 0.05},
}
-- Function to provide products to other modules
function p.get_products()
return products
end
return p