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.
Anti-spam check. Do
not
fill this in!
local p = {} -- Utility function to clean up number strings by removing commas local function cleanNumberString(value) if type(value) == 'string' then if value == 'N/A' then return -1 end return value:gsub(',', '') end return value end -- Non-dynamic module, no inputs function p.main() -- Returns only directly needed parameters for the row, -- other parameters are determined by subqueries of chained pages local query = { '[[-Sold item::~*]]', '?=Name', '?-Sold item.Shop sell price=ShopValue', '?Value=InfoboxValue', 'limit = 10000', 'order = asc' } local results = mw.smw.ask(query) local out = {} for _, item in ipairs(results) do local shopValues = item.ShopValue -- Could be an array or a single value if shopValues ~= nil then if type(shopValues) == "string" then shopValues = { shopValues } -- Normalize to a table for consistency end local infoboxValue = item.InfoboxValue if string.find(infoboxValue or '', '%S') then infoboxValue = tonumber(cleanNumberString(infoboxValue)) else infoboxValue = -2 end local hasMatch = false for _, shopValue in ipairs(shopValues) do -- Compare numeric values local cleanShopValue = cleanNumberString(shopValue) local numericShopValue = tonumber(cleanShopValue) if numericShopValue == infoboxValue then hasMatch = true end end -- Add the item to the output if any shopValue mismatched InfoboxValue if not hasMatch then table.insert(out, item) end end end -- Format the output to display each item's details local output = {} for _, item in ipairs(out) do table.insert(output, mw.text.jsonEncode(item)) -- Convert each item to a JSON string for display end return table.concat(output, '<br>') -- Concatenate the JSON representations with a line break end return p
Summary:
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
Template used on this page:
Module:Sandbox/User:Californ1a/PriceChecker/doc
(
view source
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Refresh
Search
Discord
Discord
Navigation
About us
User help
Random page
Recent changes
Ragamuffin Goblin Miner
58m
ago
-
Plav
Nuisance Goblin Miner
60m
ago
-
Plav
Wastrel Goblin Miner
1h
ago
-
Plav
Leatherworker Cape
3h
ago
-
Californ1a
Show more...
Brighter Shores
Professions
Factions
Episodes
Premium Pass
Monsters
Quests
Community
Policies
Tools
What links here
Related changes
Special pages
Page information