Module:Shops: Difference between revisions
From The Walkscape Walkthrough
Content deleted Content added
m Fix? |
mNo edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
local shops = { |
local shops = { |
||
{Icon = "File:Cabin_icon.png|frameless|32x32px", |
{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"}, |
||
{Icon = "File: |
{ShopName = "Tundra Trends", Icon = "File:Clothing_Shop.png|frameless|32x32px", Location = "Azurazera", Region = "Jarvonia"}, |
||
{Icon = "File: |
{ShopName = "Polar Pruning", Icon = "File:Barber.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"}, |
||
{Icon = "File: |
{ShopName = "Fort of Permafrost (Castle)", Icon = "File:Castle_icon.png|frameless|32x32px", Location = "Fort of Permafrost", Region = "Jarvonia"}, |
||
{ |
{ShopName = "Adventurers' Guild Outpost", Icon = "File:Adventures'_Guild_Outpost_Cabin.png|frameless|32x32px",Location = "Horn of Respite", Region = "Jarvonia"}, |
||
{ |
{ShopName = "Paws Are Us", Icon = "File:Animal_Shelter_icon.png|frameless|32x32px", Location = "Salsfirth", Region = "GDTE"}, |
||
{ |
{ShopName = "Quagmire Couture", Icon = "File:Clothing_Shop.png|frameless|32x32px", Location = "Salsfirth", Region = "GDTE"}, |
||
{ |
{ShopName = "Bog & Blade", Icon = "File:Barber.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"}, |
|||
} |
} |
||
Line 36: | Line 41: | ||
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]] || [[%s]]", shop. |
return string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region) |
||
end |
end |
||
end |
end |
||
Line 51: | Line 56: | ||
for _, shop in ipairs(shops) do |
for _, shop in ipairs(shops) do |
||
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop. |
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region)) |
||
end |
end |
||
Line 65: | Line 70: | ||
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]] || [[%s]]", shop. |
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region)) |
||
end |
end |
||
end |
end |
||
Line 80: | Line 85: | ||
for _, shop in ipairs(shops) do |
for _, shop in ipairs(shops) do |
||
if shop.Region == region then |
if shop.Region == region then |
||
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop. |
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]] || [[%s]]", shop.Icon, shop.ShopName, shop.Location, shop.Region)) |
||
end |
end |
||
end |
end |
Latest revision as of 07:03, 17 July 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 = "Tundra Trends", Icon = "File:Clothing_Shop.png|frameless|32x32px", Location = "Azurazera", Region = "Jarvonia"},
{ShopName = "Polar Pruning", Icon = "File:Barber.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 = "Adventurers' Guild Outpost", Icon = "File:Adventures'_Guild_Outpost_Cabin.png|frameless|32x32px",Location = "Horn of Respite", Region = "Jarvonia"},
{ShopName = "Paws Are Us", Icon = "File:Animal_Shelter_icon.png|frameless|32x32px", Location = "Salsfirth", Region = "GDTE"},
{ShopName = "Quagmire Couture", Icon = "File:Clothing_Shop.png|frameless|32x32px", Location = "Salsfirth", Region = "GDTE"},
{ShopName = "Bog & Blade", Icon = "File:Barber.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