Editing Module:Sandbox/User:Californ1a/PriceChecker
Jump to navigation
Jump to search
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) == |
if type(value) == "string" then |
||
⚫ | |||
if value == 'N/A' then |
|||
return -1 |
|||
⚫ | |||
⚫ | |||
end |
end |
||
return value |
return value |
||
Line 36: | Line 33: | ||
local infoboxValue = item.InfoboxValue |
local infoboxValue = item.InfoboxValue |
||
if |
if infoboxValue == nil then |
||
infoboxValue = |
infoboxValue = 0 |
||
elseif type(infoboxValue)=='string' then |
|||
else |
|||
infoboxValue = |
infoboxValue = tonumber(cleanNumberString(item.InfoboxValue)) |
||
end |
end |
||
local |
local hasMismatch = false |
||
for _, shopValue in ipairs(shopValues) do |
for _, shopValue in ipairs(shopValues) do |
||
if shopValue ~= "N/A" then |
|||
-- Compare numeric values |
|||
local |
local cleanShopValue = cleanNumberString(shopValue) |
||
local numericShopValue = tonumber(cleanShopValue) |
|||
if numericShopValue and numericShopValue ~= infoboxValue then |
|||
hasMismatch = true |
|||
break |
|||
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 |
if hasMismatch then |
||
table.insert(out, item) |
table.insert(out, item) |
||
end |
end |