Module:SellersLine

-- local p = {}

local coins_image = require('Module:Coins image')

local editbutton = require('Module:Edit button') local edit = editbutton("? (edit)") local commas = require('Module:Addcommas')._add

local free_sample = 'Free sample'

function p.main(frame) local args = frame:getParent.args

local _args = {} local store = args['store'] or edit

-- item cost local cost = string.lower(args['price'] or '') if cost == 'free' or cost == '0' or cost == 'sample' then cost = free_sample else if cost:find('%S') then cost = string.gsub(cost,',','') cost = tonumber(cost) if cost then cost = commas(cost) else cost = edit end else cost = edit end end

-- currency local currency = args['currency'] or '' if currency:find('%S') and not (string.match(currency:lower,'^coin')) and cost ~= free_sample then local currencyimg = args['currencyimg'] if currencyimg then currency = string.format('%s ',currencyimg,currency) end elseif cost == free_sample then currency = '-' else currency = string.format('%s ',coins_image(tonumber(cost) or 100),'Coins') end

-- base amount in stock local stock = args['stock'] or '' if stock:find('%S') then stock = string.gsub(stock,',','') if stock == '∞' or stock == 'inf' or stock == 'infinite' then stock = '∞' else stock = tonumber(stock) end if not stock then stock = edit end else stock = edit end

-- members only? local mems = string.lower(args['members'] or '') if mems == 'yes' then mems = true elseif mems == 'no' then mems = false else mems = 0 end

_args = { store = store, cost = cost, currency = currency, stock = stock, mems = mems}

return p._main(_args) end

function p._main(args) local memsmap = { [true] = 'Yes', [false] = 'No', [0] = edit }

local ret = mw.html.create('tr') if args.mems == true then ret:css('background','#DCDCDC') end

ret	:tag('td') :wikitext(args.store) :done :tag('td') :css('text-align','right') :wikitext(args.cost) :done :tag('td') :css('text-align','right') :wikitext(args.currency) :done :tag('td') :css('text-align','right') :wikitext(args.stock) :done :tag('td') :css('text-align','center') :wikitext(memsmap[args.mems]) :done

return ret end

return p