Editing Module:Sandbox/User:Californ1a/PriceChecker

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 3: Line 3:
-- Utility function to clean up number strings by removing commas
-- Utility function to clean up number strings by removing commas
local function cleanNumberString(value)
local function cleanNumberString(value)
if type(value) == 'string' then
if type(value) == "string" then
return value:gsub(",", "")
if value == 'N/A' then
return -1
end
return value:gsub(',', '')
end
end
return value
return value
Line 36: Line 33:
local infoboxValue = item.InfoboxValue
local infoboxValue = item.InfoboxValue
if string.find(infoboxValue or '', '%S') then
if infoboxValue == nil then
infoboxValue = tonumber(cleanNumberString(infoboxValue))
infoboxValue = 0
elseif type(infoboxValue)=='string' then
else
infoboxValue = -2
infoboxValue = tonumber(cleanNumberString(item.InfoboxValue))
end
end
local hasMatch = false
local hasMismatch = false
for _, shopValue in ipairs(shopValues) do
for _, shopValue in ipairs(shopValues) do
-- Compare numeric values
if shopValue ~= "N/A" then
local cleanShopValue = cleanNumberString(shopValue)
-- Compare numeric values
local numericShopValue = tonumber(cleanShopValue)
local cleanShopValue = cleanNumberString(shopValue)
if numericShopValue == infoboxValue then
local numericShopValue = tonumber(cleanShopValue)
hasMatch = true
if numericShopValue and numericShopValue ~= infoboxValue then
end
hasMismatch = true
break
end
end
end
end
-- Add the item to the output if any shopValue mismatched InfoboxValue
-- Add the item to the output if any shopValue mismatched InfoboxValue
if not hasMatch then
if hasMismatch then
table.insert(out, item)
table.insert(out, item)
end
end
Please note that all contributions to Brighter Shores Wiki are considered to be released under the CC BY-NC-SA 3.0 (see Brighter Shores:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template