Module:Sandbox/User:Artoire/1: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
mNo edit summary
mNo edit summary
Line 81: Line 81:


local function _lookup_price_uncached(item)
local function _lookup_price_uncached(item)
local result = tonumber(mw.smw.ask{
local result = mw.smw.ask{
('[[Sold item::%s]]'):format(item),
('[[Sold item::%s]]'):format(item),
['?Shop buy price'] = '',
['?Shop buy price'] = 'buy',
['?Shop sell price'] = 'sell',
mainlabel = '-'
mainlabel = '-'
}[1][1])
}[1]
return result or -1
return {
buy = tonumber(result.buy),
sell = tonumber(result.sell)
}
end
end


Line 189: Line 193:


local remaining_xp = target_xp - current_xp
local remaining_xp = target_xp - current_xp

local buying_ores = args.ore_buy ~= 'no'


local buying_poles = args.pole_buy
local buying_poles = args.pole_buy
Line 312: Line 318:
:td{ '[[' .. weapon.name .. ']]', addClass = 'plinkt-link no-border' }
:td{ '[[' .. weapon.name .. ']]', addClass = 'plinkt-link no-border' }


local cost = needed_ores * lookup_price(ingot.ore)
local cost = needed_ores * lookup_price(ingot.ore)[buying_ores and 'buy' or 'sell']
if chopping_logs then
if chopping_logs then
-- No extra cost
if needed_logs then
cost = cost + needed_logs * lookup_price(pole_info.log).sell
end
elseif buying_logs then
elseif buying_logs then
if needed_logs then
if needed_logs then
cost = cost + needed_logs * lookup_price(pole_info.log)
cost = cost + needed_logs * lookup_price(pole_info.log).buy
end
end
else
else
if weapon.pole then
if weapon.pole then
cost = cost + needed_poles * lookup_price(weapon.pole.name)
cost = cost + needed_poles * lookup_price(weapon.pole.name).buy
end
end
end
end