Home
Random
Log in
Settings
About the RuneScape Classic Wiki
Disclaimers
RuneScape Classic Wiki
Search
Editing
Module:Store locations list
Warning:
You are not logged in. Once you make an edit, a temporary account will be created for you.
Learn more
.
Log in
or
create an account
to continue receiving notifications after this account expires, and to access other features.
Anti-spam check. Do
not
fill this in!
-- <pre> local p = {} local commas = require("Module:Addcommas")._add local params = require('Module:Paramtest') local yesno = require("Module:Yesno") local p2pIcon = '[[File:Member icon.png|frameless|link=Pay-to-play]]' local f2pIcon = '[[File:Free-to-play icon.png|frameless|link=Free-to-play]]' function p.main(frame) local args = frame:getParent().args local item,limit = params.defaults{ {args[1],mw.title.getCurrentTitle().text}, {args.Limit,100} } mw.log(string.format('Searching for shops that sell: %s', item)) -- Get parsed bucket data local data = getData(item,limit) -- Create the header of the output local headerText = "" local restbl = mw.html.create('table') restbl:addClass('wikitable sortable align-center-3 align-center-4 align-center-5 align-center-6') :tag('tr') :tag('th'):wikitext('Seller'):done() :tag('th'):wikitext('Location'):done() :tag('th'):wikitext('Number<br>in stock'):attr('data-sort-type', 'number'):done() :tag('th'):wikitext('Price<br>sold at'):attr('data-sort-type', 'number'):done() :tag('th'):wikitext('Price<br>bought at'):attr('data-sort-type', 'number'):done() :tag('th'):wikitext('Members'):done() :done() -- Create the rows for the output table for _, shop in ipairs(data) do restbl:tag('tr') :tag('td'):wikitext('[['..shop.seller..']]'):done() :tag('td'):wikitext(shop.location):done() :tag('td') :attr({['data-sort-value']=shop.stockSortValue}) :wikitext(shop.stock) :done() :tag('td') :attr({['data-sort-value']=shop.sellSortValue}) :wikitext(shop.sellvalue) :done() :tag('td') :attr({['data-sort-value']=shop.buySortValue}) :wikitext(shop.buyvalue) :done() :tag('td'):wikitext(shop.members):done() :done() end return headerText .. tostring(restbl) end function getData(itemName,args,limit) local data = bucket('storeline') .select( 'page_name', 'sold_item', 'sold_item_text', 'sold_item_image', 'store_buy_price', 'store_sell_price', 'store_stock', 'infobox_shop.is_members_only', 'infobox_shop.location' ) .join('infobox_shop', 'infobox_shop.page_name', 'page_name') .where('sold_item', itemName) .limit(tonumber(limit)) .orderBy('store_sell_price', 'asc') .run() if #data == 0 then error('The item "' .. itemName .. '" is not sold in any shop, please check for typos[[Category:Empty store lists]]', 0) end -- Loop over data local retdata = {} for _, item in ipairs(data) do local dataline = processData(item, editbtn) table.insert(retdata, dataline) end return retdata end function processData(item, editbtn) local seller = item.page_name local location = item['infobox_shop.location'] or editbtn local stock = item.store_stock or '' local stockSortValue = 0 if stock == 'β' then stock = '<span style="font-size:120%;">β</span>' stockSortValue = '10e50' elseif stock == 'N/A' then stockSortValue = '10e99' else stock = tonumber(stock) if stock then stockSortValue = stock stock = commas(stock) else stock = editbtn -- If stock can't be converted to a number it will default to the edit button end end local sellvalue = item.store_sell_price or '' local sellSortValue = 0 if not(sellvalue == 1e10) then sellvalue = tonumber(sellvalue) if sellvalue then sellSortValue = sellvalue sellvalue = '[[File:Coins.png|link=Coins]] ' .. commas(sellvalue) else sellvalue = editbtn -- If sellvalue can't be converted to a number it will default to the edit button end else sellSortValue = sellvalue sellvalue = 'N/A' end local buyvalue = item.store_buy_price or '' local buySortValue = 0 if not(buyvalue == 'N/A') then buyvalue = tonumber(buyvalue) if buyvalue then buySortValue = buyvalue buyvalue = '[[File:Coins.png|link=Coins]] ' .. commas(buyvalue) else buyvalue = editbtn -- If sellvalue can't be converted to a number it will default to the edit button end end -- members only? local members = item['infobox_shop.is_members_only'] if yesno(members) == true then members = p2pIcon elseif yesno(members) == false then members = f2pIcon -- Unsupported type for yesno, default to editbtn else members = editbtn end return { seller = seller, location = location, stock = stock, stockSortValue = stockSortValue, sellvalue = sellvalue, sellSortValue = sellSortValue, buyvalue = buyvalue, buySortValue = buySortValue, members = members } end function editbutton(title) local link = string.gsub(mw.title.getCurrentTitle():fullUrl("action=edit"), mw.title.getCurrentTitle().fullText, title) link = string.gsub(link, ' ', '_') link = string.format("<span class='plainlinks'>[%s '''?''' (edit)]</span>", link) return link end return p
Summary:
Please note that all contributions to RuneScape Classic Wiki are considered to be released under the CC BY-NC-SA 3.0 (see
RuneScape: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
Page included on this page:
Module:Store locations list/doc
(
edit
)