Module:Shops
From The Walkscape Walkthrough
Documentation for this module may be created at Module:Shops/doc
local p = {}
local shops = {
{Icon = "File:Cabin_icon.png|frameless|32x32px", ShopName = "Helpful Herbert's Hut", Location = "Disenchanted Forest", Region = "Jarvonia"},
{Icon = "File:Temple_of_Azurazera_icon.png|frameless|32x32px", ShopName = "Temple of Azurazera", Location = "Azurazera", Region = "Jarvonia"},
{Icon = "File:Tavern_icon.png|frameless|32x32px", ShopName = "The Icy Goblet", Location = "Kallaheim", Region = "Jarvonia"},
{Icon = "File:General_Store_icon.png|frameless|32x32px", ShopName = "Kallaheim's Frosty Finds", Location = "Kallaheim", Region = "Jarvonia"},
{Icon = "File:General_Store_icon.png|frameless|32x32px", ShopName = "Jarvojoy", Location = "Frusenholm", Region = "Jarvonia"},
{Icon = "File:General_Store_icon.png|frameless|32x32px", ShopName = "Northstar Mercantile", Location = "Centaham", Region = "Jarvonia"},
{Icon = "File:Fishing_Shop_icon.png|frameless|32x32px", ShopName = "Frosthook Emporium", Location = "Port Skildar", Region = "Jarvonia"},
{Icon = "File:Cabin_icon.png|frameless|32x32px", ShopName = "Woodcutter's Cabin", Location = "Nomad Woods", Region = "Jarvonia"},
{Icon = "File:Castle_icon.png|frameless|32x32px", ShopName = "Fort of Permafrost (Castle)", Location = "Fort of Permafrost", Region = "Jarvonia"},
{Icon = "File:Animal_Shelter_icon.png|frameless|32x32px", ShopName = "Paws Are Us", Location = "Salsfirth", Region = "GDTE"},
{Icon = "File:General_Store_icon.png|frameless|32x32px", ShopName = "Mossy Merchant's Breeze Mart", Location = "Everhaven", Region = "GDTE"},
{Icon = "File:Castle_icon.png|frameless|32x32px", ShopName = "Bilgemont Castle", Location = "Bilgemont Port", Region = "GDTE"},
{Icon = "File:Market_Stall_icon.png|frameless|32x32px", ShopName = "Fish Market Stall", Location = "Granfiddich", Region = "GDTE"},
{Icon = "File:Market_Stall_icon.png|frameless|32x32px", ShopName = "Food Market Stall", Location = "Granfiddich", Region = "GDTE"},
{Icon = "File:Market_Stall_icon.png|frameless|32x32px", ShopName = "Tool Market Stall", 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.ShopIcon, 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.ShopIcon, 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.ShopIcon, 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.ShopIcon, shop.ShopName, shop.Location, shop.Region))
end
end
table.insert(rows, "|}")
return table.concat(rows, "\n")
end
return p