Module:Sandbox/User:Alsang/NodeDescriptionChecker: Difference between revisions

save as WIP for passive stonemason
(tidy up column headings)
(save as WIP for passive stonemason)
Line 21:
--'[[Uses facility::Knickknacks workbench]] OR [[Variant of::Divination||Sabertooth Cat Skeleton||Wooly Mammoth Skeleton||Triceratops Skeleton||T-Rex Skeleton||Wendigo Skeleton||Bonemeal Cement]]', -- bonewright passive
--'[[Uses facility::One Handed Range (stonemason)||One Handed Melee Workbench (stonemason)||Two Handed Range Workbench (stonemason)||Two Handed Melee Workbench (stonemason)||Shield Vice (stonemason)]]', -- stonemason active
--'[[Uses facility::Stoneware benchBench]] OR [[Variant of::Statue Sculpture||Ornamental Scuplture||Column Sculpture||Bust Sculpture]]', -- stonemason passive
--'[[Uses facility::Goblin Forge||Gnome Forge (skill node)]]', -- blacksmith active
--'[[Uses facility::Jewelry Bench]]', -- blacksmith passive, no non-recipe
'[[-Sold item.Sold by::Leather stall]][[Recipe JSON::~*]]', -- leatherworker active, the stall sells scraps and we need to ignore those
--'[[-Sold item.Sold by::Leather Goods]] OR [[Variant of::Upholstery]]', -- leatherworker passive, but the Upholstery activities dont have pages yet
'?Uses facility #- = facility',
'?Profession Level A = lvl',
Line 41 ⟶ 39:
-- criterion for if an entry is a recipe, or a passive activity
for _, item in ipairs(results) do
--item.passiveActivity = false -- can delete this entire FOR statement unless there are non-recipe passive activities on the table
--item.passiveActivity = not(item.facility=='UpholsteryStoneware stationBench') -- leatherworker has not got upholstery implemented yet, do not use
end
Line 71 ⟶ 69:
function p.formatResults(results)
local discountList = discount.main()
 
-- iterate through products
for _, item in ipairs(results) do
Line 103 ⟶ 99:
-- iterate through materials, adding buy price to running total (individuals not needed)
item.buy = 0
item.buyDiscount = 0
for _, material in ipairs(item.materials) do
Line 119 ⟶ 114:
item.buy = item.buy and item.buy + shopPrice * material.quantity
--with the merchant discount, buy price is sell price
local shopPriceQuery = '[[:+]][[Sold item::' .. material.name .. ']]|?Shop sell price|mainlabel=' .. material.name
local shopPriceResult = mw.smw.ask(shopPriceQuery) or {}
local shopPrice = 0
if shopPriceResult[1] and shopPriceResult[1]["Shop sell price"] then
shopPrice = tonumber(shopPriceResult[1]["Shop sell price"]) or 0
else
item.buyDiscount = nil
end
item.buyDiscount = item.buyDiscount and item.buyDiscount + shopPrice * material.quantity
end
Line 178 ⟶ 160:
item.sell = item.sell and item.outputQuantity and item.sell * item.outputQuantity
item.profit = item.sell and item.buy and item.sell - item.buy
item.profitDiscount = item.sell and item.buyDiscount and item.sell - item.buyDiscount
item.profitPerXP = item.profit and item.XP and math.floor(item.profit / item.XP * 100) / 100
item.profitPerXPDiscount = item.profitDiscount and item.XP and math.floor(item.profitDiscount / item.XP * 100) / 100
local hideName = string.gsub(item.name,'Leather','Hide')
item.discountLevel = discountList[hideName]
 
-- a lot of downtime in leatherworker
Line 194 ⟶ 172:
item.XPPerHour = item.XP and item.productPerHour and math.floor(item.XP * item.productPerHour)
item.profitPerHour = item.profit and item.productPerHour and math.floor(item.profit * item.productPerHour)
item.profitPerHourDiscount = item.profitDiscount and item.productPerHour and math.floor(item.profitDiscount * item.productPerHour)
end
 
Line 206 ⟶ 183:
:tag('tr')
:tag('th')
:wikitext('[[File:LeatherworkerStonemason small icon.png|15px]] Level')
:done()
:tag('th')
Line 215 ⟶ 192:
:wikitext('Materials')
:done()
-- :tag('th')
-- :attr{ colspan = '10' }
-- :wikitext('Buy Value')
-- :done()
-- :tag('th')
-- :attr{ colspan = '10' }
-- :wikitext('Sell Value')
-- :done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Profit/itemBuy Value')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Profit/hrSell Value')
:done()
:tag('th')
-- :attr{ colspan = '10' }
:wikitext('[[File:Merchant_small_icon.png|18px]] level<br>for discount')
-- :wikitext('Buy ValueProfit')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Profit/hr with [[File:Merchant_small_icon.png|18px]] discount')
:done()
:tag('th')
Line 244 ⟶ 214:
:wikitext('XP/hr')
:done()
-- :tag('th')
-- :attr{ colspan = '10' }
-- :wikitext('Coins/XP')
-- :done()
-- :tag('th')
-- :attr{ colspan = '10' }
-- :wikitext('Coins/XP with [[File:Merchant_small_icon.png|18px]] discount')
-- :done()
:done()
 
Line 294 ⟶ 260:
row
-- :node(currency_cell(item.buy))
-- :node(currency_cell(item.sell))
:ELSE()
Line 309 ⟶ 275:
:node(currency_cell(item.profitPerHour))
:tag('td')
:css{ ['text-align'] = 'center' }
:wikitext(item.discountLevel)
:done()
:node(currency_cell(item.profitPerHourDiscount))
 
:IF(item.XP)
:tag('td')
Line 331 ⟶ 291:
:END()
 
-- :node(currency_cell(item.profitPerXP))
-- :node(currency_cell(item.profitPerXPDiscount))
 
:done()
21,285

edits