Module:Shops: Difference between revisions
From The Walkscape Walkthrough
Content added Content deleted
CptRileyyy (talk | contribs) (Add table terminators) |
m (JarvoJoy) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
local shops = { |
local shops = { |
||
{ShopName = "Helpful Herbert's Hut", Location = "Disenchanted Forest", |
{ShopName = "Helpful Herbert's Hut", Icon = "File:Cabin_icon.png|frameless|32x32px", Location = "Disenchanted Forest", Region = "Jarvonia"}, |
||
{ShopName = "Temple of Azurazera", Location = "Azurazera", |
{ShopName = "Temple of Azurazera", Icon = "File:Temple_of_Azurazera_icon.png|frameless|32x32px", Location = "Azurazera", Region = "Jarvonia"}, |
||
{ShopName = "The Icy Goblet", Location = "Kallaheim", |
{ShopName = "The Icy Goblet", Icon = "File:Tavern_icon.png|frameless|32x32px", Location = "Kallaheim", Region = "Jarvonia"}, |
||
{ShopName = "Kallaheim's Frosty Finds", Location = "Kallaheim", |
{ShopName = "Kallaheim's Frosty Finds", Icon = "File:General_Store_icon.png|frameless|32x32px", Location = "Kallaheim", Region = "Jarvonia"}, |
||
{ShopName = " |
{ShopName = "JarvoJoy", Icon = "File:General_Store_icon.png|frameless|32x32px", Location = "Frusenholm", Region = "Jarvonia"}, |
||
{ShopName = "Northstar Mercantile", Location = "Centaham", |
{ShopName = "Northstar Mercantile", Icon = "File:General_Store_icon.png|frameless|32x32px", Location = "Centaham", Region = "Jarvonia"}, |
||
{ShopName = "Frosthook Emporium", Location = "Port Skildar", |
{ShopName = "Frosthook Emporium", Icon = "File:Fishing_Shop_icon.png|frameless|32x32px", Location = "Port Skildar", Region = "Jarvonia"}, |
||
{ShopName = "Woodcutter's Cabin", Location = "Nomad Woods", |
{ShopName = "Woodcutter's Cabin", Icon = "File:Cabin_icon.png|frameless|32x32px", Location = "Nomad Woods", Region = "Jarvonia"}, |
||
{ShopName = "Fort of Permafrost", Location = "Fort |
{ShopName = "Fort of Permafrost (Castle)", Icon = "File:Castle_icon.png|frameless|32x32px", Location = "Fort of Permafrost", Region = "Jarvonia"}, |
||
{ShopName = "Paws Are Us", Location = "Salsfirth", |
{ShopName = "Paws Are Us", Icon = "File:Animal_Shelter_icon.png|frameless|32x32px", Location = "Salsfirth", Region = "GDTE"}, |
||
{ShopName = "Mossy Merchant's Breeze Mart", Location = "Everhaven", |
{ShopName = "Mossy Merchant's Breeze Mart", Icon = "File:General_Store_icon.png|frameless|32x32px", Location = "Everhaven", Region = "GDTE"}, |
||
{ShopName = "Bilgemont Castle", Location = "Bilgemont Port", |
{ShopName = "Bilgemont Castle", Icon = "File:Castle_icon.png|frameless|32x32px", Location = "Bilgemont Port", Region = "GDTE"}, |
||
{ShopName = "Fish Market Stall", Location = "Granfiddich", |
{ShopName = "Fish Market Stall", Icon = "File:Market_Stall_icon.png|frameless|32x32px", Location = "Granfiddich", Region = "GDTE"}, |
||
{ShopName = "Food Market Stall", Location = "Granfiddich", |
{ShopName = "Food Market Stall", Icon = "File:Market_Stall_icon.png|frameless|32x32px", Location = "Granfiddich", Region = "GDTE"}, |
||
{ShopName = "Tool Market Stall", Location = "Granfiddich", |
{ShopName = "Tool Market Stall", Icon = "File:Market_Stall_icon.png|frameless|32x32px", Location = "Granfiddich", Region = "GDTE"}, |
||
} |
} |
||
Line 36: | Line 36: | ||
for _, shop in ipairs(shops) do |
for _, shop in ipairs(shops) do |
||
if shop.ShopName == shopName then |
if shop.ShopName == shopName then |
||
return string.format("|-\n| [[%s]] || [[%s]] || [[%s]]", shop.ShopName, shop.Location, shop. |
return string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region) |
||
end |
end |
||
end |
end |
||
Line 48: | Line 48: | ||
function p.getAllShops() |
function p.getAllShops() |
||
local rows = {} |
local rows = {} |
||
table.insert(rows, "{| class=\"wikitable\"\n! Shop Name !! Location !! |
table.insert(rows, "{| class=\"wikitable sortable\" style=\"text-align: center;\"\n! !Icon !! Shop Name !! Location !! Region") |
||
for _, shop in ipairs(shops) do |
for _, shop in ipairs(shops) do |
||
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]]", shop.ShopName, shop.Location, shop. |
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region)) |
||
end |
end |
||
Line 61: | Line 61: | ||
local location = frame.args[1] |
local location = frame.args[1] |
||
local rows = {} |
local rows = {} |
||
table.insert(rows, string.format("{| class=\"wikitable\"\n! Shop Name !! Location !! |
table.insert(rows, string.format("{| class=\"wikitable sortable\" style=\"text-align: center;\"\n! !Icon !! Shop Name !! Location !! Region")) |
||
for _, shop in ipairs(shops) do |
for _, shop in ipairs(shops) do |
||
if shop.Location == location then |
if shop.Location == location then |
||
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]]", shop.ShopName, shop.Location, shop. |
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region)) |
||
end |
end |
||
end |
end |
||
Line 73: | Line 73: | ||
end |
end |
||
function p. |
function p.getAllShopsByRegion(frame) |
||
local region = frame.args[1] |
local region = frame.args[1] |
||
local rows = {} |
local rows = {} |
||
table.insert(rows, string.format("{| class=\"wikitable\"\n! Shop Name !! Location !! |
table.insert(rows, string.format("{| class=\"wikitable sortable\" style=\"text-align: center;\"\n! !Icon !! Shop Name !! Location !! Region")) |
||
for _, shop in ipairs(shops) do |
for _, shop in ipairs(shops) do |
||
if shop. |
if shop.Region == region then |
||
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]]", shop.ShopName, shop.Location, shop. |
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region)) |
||
end |
end |
||
end |
end |
Revision as of 05:19, 25 March 2024
Documentation for this module may be created at Module:Shops/doc
local p = {}
local shops = {
{ShopName = "Helpful Herbert's Hut", Icon = "File:Cabin_icon.png|frameless|32x32px", Location = "Disenchanted Forest", Region = "Jarvonia"},
{ShopName = "Temple of Azurazera", Icon = "File:Temple_of_Azurazera_icon.png|frameless|32x32px", Location = "Azurazera", Region = "Jarvonia"},
{ShopName = "The Icy Goblet", Icon = "File:Tavern_icon.png|frameless|32x32px", Location = "Kallaheim", Region = "Jarvonia"},
{ShopName = "Kallaheim's Frosty Finds", Icon = "File:General_Store_icon.png|frameless|32x32px", Location = "Kallaheim", Region = "Jarvonia"},
{ShopName = "JarvoJoy", Icon = "File:General_Store_icon.png|frameless|32x32px", Location = "Frusenholm", Region = "Jarvonia"},
{ShopName = "Northstar Mercantile", Icon = "File:General_Store_icon.png|frameless|32x32px", Location = "Centaham", Region = "Jarvonia"},
{ShopName = "Frosthook Emporium", Icon = "File:Fishing_Shop_icon.png|frameless|32x32px", Location = "Port Skildar", Region = "Jarvonia"},
{ShopName = "Woodcutter's Cabin", Icon = "File:Cabin_icon.png|frameless|32x32px", Location = "Nomad Woods", Region = "Jarvonia"},
{ShopName = "Fort of Permafrost (Castle)", Icon = "File:Castle_icon.png|frameless|32x32px", Location = "Fort of Permafrost", Region = "Jarvonia"},
{ShopName = "Paws Are Us", Icon = "File:Animal_Shelter_icon.png|frameless|32x32px", Location = "Salsfirth", Region = "GDTE"},
{ShopName = "Mossy Merchant's Breeze Mart", Icon = "File:General_Store_icon.png|frameless|32x32px", Location = "Everhaven", Region = "GDTE"},
{ShopName = "Bilgemont Castle", Icon = "File:Castle_icon.png|frameless|32x32px", Location = "Bilgemont Port", Region = "GDTE"},
{ShopName = "Fish Market Stall", Icon = "File:Market_Stall_icon.png|frameless|32x32px", Location = "Granfiddich", Region = "GDTE"},
{ShopName = "Food Market Stall", Icon = "File:Market_Stall_icon.png|frameless|32x32px", Location = "Granfiddich", Region = "GDTE"},
{ShopName = "Tool Market Stall", Icon = "File:Market_Stall_icon.png|frameless|32x32px", Location = "Granfiddich", Region = "GDTE"},
}
function p.getShopData(frame)
local shopName = frame.args[1]
for _, shop in ipairs(shops) do
if shop.ShopName == shopName then
return shop
end
end
return "Shop not found"
end
function p.getShopData_AsTableRow(frame)
-- Extract the shop name from the frame arguments
local shopName = frame.args[1]
for _, shop in ipairs(shops) do
if shop.ShopName == shopName then
return string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region)
end
end
return string.format("Shop %s not found", shopName)
end
function p.getShops()
return shops
end
function p.getAllShops()
local rows = {}
table.insert(rows, "{| class=\"wikitable sortable\" style=\"text-align: center;\"\n! !Icon !! Shop Name !! Location !! Region")
for _, shop in ipairs(shops) do
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region))
end
table.insert(rows, "|}")
return table.concat(rows, "\n")
end
function p.getAllShopsByLocation(frame)
local location = frame.args[1]
local rows = {}
table.insert(rows, string.format("{| class=\"wikitable sortable\" style=\"text-align: center;\"\n! !Icon !! Shop Name !! Location !! Region"))
for _, shop in ipairs(shops) do
if shop.Location == location then
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region))
end
end
table.insert(rows, "|}")
return table.concat(rows, "\n")
end
function p.getAllShopsByRegion(frame)
local region = frame.args[1]
local rows = {}
table.insert(rows, string.format("{| class=\"wikitable sortable\" style=\"text-align: center;\"\n! !Icon !! Shop Name !! Location !! Region"))
for _, shop in ipairs(shops) do
if shop.Region == region then
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region))
end
end
table.insert(rows, "|}")
return table.concat(rows, "\n")
end
return p