Module:Shops: Difference between revisions
From The Walkscape Walkthrough
Content added Content deleted
CptRileyyy (talk | contribs) (Add some debugging to figure out why this isnt working in a page) |
CptRileyyy (talk | contribs) (force param to be a string, even though it should be) |
||
Line 25: | Line 25: | ||
end |
end |
||
end |
end |
||
return |
return "Shop not found" |
||
end |
end |
||
function p.getShopData_AsTableRow(shopName) |
function p.getShopData_AsTableRow(shopName) |
||
-- Ensure shopName is a string |
|||
if type(shopName) ~= "string" then |
|||
shopName = tostring(shopName) |
|||
end |
|||
local o = {} |
local o = {} |
||
for _, shop in ipairs(shops) do |
for _, shop in ipairs(shops) do |
Revision as of 00:49, 8 March 2024
Documentation for this module may be created at Module:Shops/doc
local p = {}
local shops = {
{ShopName = "Helpful Herbert's Hut", Location = "DisenchantedForest", Realm = "Jarvonia"},
{ShopName = "Temple of Azurazera", Location = "Azurazera", Realm = "Jarvonia"},
{ShopName = "The Icy Goblet", Location = "Kallaheim", Realm = "Jarvonia"},
{ShopName = "Kallaheim's Frosty Finds", Location = "Kallaheim", Realm = "Jarvonia"},
{ShopName = "Jarvojoy", Location = "Frusenholm", Realm = "Jarvonia"},
{ShopName = "Northstar Mercantile", Location = "Centaham", Realm = "Jarvonia"},
{ShopName = "Frosthook Emporium", Location = "PortSkildar", Realm = "Jarvonia"},
{ShopName = "Woodcutter's Cabin", Location = "NomadWoods", Realm = "Jarvonia"},
{ShopName = "Fort of Permafrost", Location = "FortOfPermafrost", Realm = "Jarvonia"},
{ShopName = "Paws Are Us", Location = "Salsfirth", Realm = "GDTE"},
{ShopName = "Mossy Merchant's Breeze Mart", Location = "Everhaven", Realm = "GDTE"},
{ShopName = "Bilgemont Castle", Location = "BilgemontPort", Realm = "GDTE"},
{ShopName = "Fish Market Stall", Location = "Granfiddich", Realm = "GDTE"},
{ShopName = "Food Market Stall", Location = "Granfiddich", Realm = "GDTE"},
{ShopName = "Tool Market Stall", Location = "Granfiddich", Realm = "GDTE"},
}
function p.getShopData(shopName)
for _, shop in ipairs(shops) do
if shop.ShopName == shopName then
return shop
end
end
return "Shop not found"
end
function p.getShopData_AsTableRow(shopName)
-- Ensure shopName is a string
if type(shopName) ~= "string" then
shopName = tostring(shopName)
end
local o = {}
for _, shop in ipairs(shops) do
table.insert(o, string.format("shop.ShopName: %s did not match input of %s", shop.ShopName, shopName))
if shop.ShopName == shopName then
return string.format("|-\n| [[%s]] || [[%s]] || [[%s]]", shop.ShopName, shop.Location, shop.Realm)
end
end
return table.concat(o, "\n")
end
function p.getAllShops()
return shops
end
function p.getAllShops_AsTableRows()
local rows = {}
for _, shop in ipairs(shops) do
table.insert(rows, string.format("|-\n| [[%s]] || [[%s]] || [[%s]]", shop.ShopName, shop.Location, shop.Realm))
end
return table.concat(rows, "\n")
end
return p