1,131
edits
No edit summary |
No edit summary |
||
| (17 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
-------------------------- | |||
-- Module for [[Template:StoreLine]] | |||
-- | |||
-- | |||
------------------------ | |||
local p = {} | local p = {} | ||
local lang = mw.language.getContentLanguage() | local lang = mw.language.getContentLanguage() | ||
| Line 27: | Line 33: | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
-- Params and defaults | -- Params and defaults | ||
local name, buyvalue, sellvalue, currency, level = params.defaults{ | local name, buyvalue, sellvalue, currency, level, members = params.defaults{ | ||
{args.name or args.Name, ''}, | {args.name or args.Name, ''}, | ||
{args.buy or args.Buy, ''}, | {args.buy or args.Buy, 'N/A'}, | ||
{args.sell or args.Sell, ''}, | {args.sell or args.Sell, 'N/A'}, | ||
{args.currency or args.Currency, 'Gold'}, | {args.currency or args.Currency, 'Gold'}, | ||
{args.level or args.Level, '?'}, | {args.level or args.Level, '?'}, | ||
{args.members or args.Members, 'No'}, | |||
} | } | ||
local itemvalue = '' | local itemvalue = '' | ||
| Line 40: | Line 47: | ||
-- Lookup SMW value | -- Lookup SMW value | ||
if itemvalue == '' then | --if itemvalue == '' then | ||
-- itemvalue = getSMWInfo(smwname) or '' | |||
end | --end | ||
-- Check precached Module:DropsLine/itemData - gets GE alch so inaccurate | -- Check precached Module:DropsLine/itemData - gets GE alch so inaccurate | ||
| Line 62: | Line 69: | ||
local hidebuy = yesno(var.var('hideBuy','no'), false) | local hidebuy = yesno(var.var('hideBuy','no'), false) | ||
local hidelevel = yesno(var.var('hideLevel','no'), false) | local hidelevel = yesno(var.var('hideLevel','no'), false) | ||
local hidemembers = yesno(var.var('hideMembers', 'no'), false) | |||
buyvalue = commas._strip(buyvalue) | buyvalue = commas._strip(buyvalue) | ||
sellvalue = commas._strip(sellvalue) | sellvalue = commas._strip(sellvalue) | ||
levelvalue = commas._strip(level) | levelvalue = commas._strip(level) | ||
local buy_smw = tonumber(buyvalue) | local buy_smw = tonumber(buyvalue) or 1e10 | ||
local sell_smw = tonumber(sellvalue) or 1e10 | local sell_smw = tonumber(sellvalue) or 1e10 | ||
local level_smw = tonumber(levelvalue) or 1e10 | local level_smw = tonumber(levelvalue) or 1e10 | ||
local members_smw = members | |||
local buyCurrency = '' | local buyCurrency = '' | ||
local sellCurrency = '' | local sellCurrency = '' | ||
| Line 74: | Line 83: | ||
if buyvalue ~= 'N/A' then | if buyvalue ~= 'N/A' then | ||
if buyvalue == '' and itemvalue ~= '' then | if buyvalue == '' and itemvalue ~= '' then | ||
buyvalue = math.floor(math.max(itemvalue*buymultiplier/1000, | buyvalue = math.floor(math.max(itemvalue*buymultiplier/1000,1)) | ||
buy_smw = buyvalue | buy_smw = buyvalue | ||
end | end | ||
| Line 80: | Line 89: | ||
end | end | ||
if sellvalue ~= 'N/A' then | if sellvalue ~= 'N/A' then | ||
if sellvalue == '' and itemvalue ~= '' then | if sellvalue == '' and itemvalue ~= '' then | ||
sellvalue = math.floor(math.max(itemvalue*sellmultiplier/1000,1)) | sellvalue = math.floor(math.max(itemvalue*sellmultiplier/1000,1)) | ||
sell_smw = sellvalue | sell_smw = sellvalue | ||
end | end | ||
sellvalue = showCurrencyAmount(currency, sellvalue) | sellvalue = showCurrencyAmount(currency, sellvalue) | ||
end | end | ||
local ret = mw.html.create('tr'):css('text-align','center') | local ret = mw.html.create('tr'):css('text-align','center') | ||
if not hideimage then | if not hideimage then | ||
ret:tag('td'):wikitext(mw.ustring.format('[[%s|link=%s| | ret:tag('td'):wikitext(mw.ustring.format('[[%s|link=%s|32px]]', image, name)) | ||
end | end | ||
-- no hideXXX parameter for the column that lists the actual items. | -- no hideXXX parameter for the column that lists the actual items. | ||
ret:tag('td'):css('text-align','left'):wikitext(mw.ustring.format('[[%s|%s]]', name, displayname)) | ret:tag('td'):css('text-align','left'):wikitext(mw.ustring.format('[[%s|%s]]', name, displayname)) | ||
if not hidesell then | if not hidebuy then | ||
if buyvalue=='N/A' then | |||
ret:tag('td'):attr('data-sort-value', 0):attr('class','table-na'):wikitext('<small>N/A</small>'):done() | |||
else | |||
ret:tag('td') | |||
:attr('data-sort-value', buy_smw or 0) | |||
:wikitext(buyvalue) | |||
:done() | |||
end | |||
end | |||
if not hidesell then | |||
if sellvalue == 'N/A' then | if sellvalue == 'N/A' then | ||
ret:tag('td'):attr('data-sort-value', 0):attr('class','table-na'):wikitext('<small>N/A</small>'):done() | ret:tag('td'):attr('data-sort-value', 0):attr('class','table-na'):wikitext('<small>N/A</small>'):done() | ||
| Line 110: | Line 123: | ||
else | else | ||
ret:tag('td') | ret:tag('td') | ||
:attr('data-sort-value', sell_smw) | :attr('data-sort-value', sell_smw or 0) | ||
:wikitext(sellvalue) | :wikitext(sellvalue) | ||
:done() | :done() | ||
end | end | ||
end | end | ||
| Line 135: | Line 138: | ||
:done() | :done() | ||
end | end | ||
end | |||
if not hidemembers then | |||
if members == 'N/A' then | |||
ret:tag('td'):attr('data-sort-value', 0):attr('class','table-na'):wikitext('<small>N/A</small>'):done() | |||
else | |||
ret:tag('td') | |||
:attr('data-sort-value', members_smw or 0) | |||
:wikitext(members) | |||
:done() | |||
end | |||
end | |||
local i = 1 | local i = 1 | ||
| Line 158: | Line 172: | ||
smw_sub['Sold item'] = name | smw_sub['Sold item'] = name | ||
smw_sub['Sold item text'] = displayname | smw_sub['Sold item text'] = displayname | ||
smw_sub['Store sell price'] = sell_smw --type = number for sorting purposes | smw_sub['Store sell price'] = sell_smw or 'N/A' --type = number for sorting purposes | ||
smw_sub['Store buy price'] = buy_smw or 'N/A' | smw_sub['Store buy price'] = buy_smw or 'N/A' | ||
smw_sub['Store currency'] = currency | smw_sub['Store currency'] = currency | ||
smw_sub['Store notes'] = namenotes | smw_sub['Store notes'] = namenotes | ||
smw_sub['Is members only'] = members | |||
mw.smw.subobject(smw_sub) -- add item subobject to page | mw.smw.subobject(smw_sub) -- add item subobject to page | ||