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

m
no edit summary
mNo edit summary
mNo edit summary
 
Line 3:
current_xp = 24,
target_xp = 37,
ingot = 'MaloicCoarse AdathrilDeathstone Ingot(Etched)',
profession = 'Stonemason', -- 'Bonewright'/'Stonemason'/'Blacksmith'
ore_buy = 'true',
pole_buy = 'none', -- 'none'/'logs'/'pole'
Line 15 ⟶ 16:
local lang = mw.language.getContentLanguage()
 
local _ingots = {}
local function lookup_ingots(profession)
if _ingots[profession] then
return _ingots[profession]
end
_ingots[profession] = {
recipes = {},
order = {}
}
for _, result in ipairs(mw.smw.ask{
})({
Blacksmith = '[[Uses facility::Goblin Smelter||Gnome Smelter]]',
Stonemason = '[[Uses facility::T.E.A. Machine]]',
Bonewright = '[[Uses facility::B.R.E.W.S. Vat]]'
})[profession],
['?Recipe JSON'] = '',
mainlabel = '-',
Line 33 ⟶ 38:
result = mw.text.jsonDecode(result[1])
local ingot = result.output[1].name
_ingots[profession].recipes[ingot] = {
xp = result.xp,
facility = result.facility,
Line 40 ⟶ 45:
level = result.level
}
table.insert(_ingots[profession].order, ingot)
end
return _ingots[profession]
end
 
local function lookup_weapons(profession)
local ingots = lookup_ingots(profession)
local weapons = {}
for _, result in ipairs(mw.smw.ask{
({
Blacksmith = '[[Uses facility::Goblin Forge||Gnome Forge]]',
Stonemason = '[[Category:Stonemason]][[Category:Pages with recipes]][[Uses facility::!T.E.A. Machine]]',
Bonewright = '[[Category:Bonewright]][[Category:Pages with recipes]][[Uses facility::!B.R.E.W.S. Vat]]'
})[profession],
['?Recipe JSON'] = '',
mainlabel = '-',
Line 57 ⟶ 66:
local lvl = result['Profession Level A']
result = mw.text.jsonDecode(result[1])
if not result.passive and result.profession == profession then
local ingot
local poleingot
local ingotpole
for _, material in ipairs(result.materials) do
iffor _, ingots.recipes[material in ipairs(result.name]materials) thendo
if ingots.recipes[material.name] then
assert(not ingot)
assert(not ingot = material)
ingot = ingot,material
else
assert(not pole)
assert(not pole = material)
pole = pole,material
end
end
weapons[ingot.name] = weapons[ingot.name] or {}
table.insert(weapons[ingot.name], {
facility = result.facility,
level = result.level,
assert(notingot = ingot),
assert(notpole = pole),
name = result.output[1].name,
xp = result.xp
})
end
weapons[ingot.name] = weapons[ingot.name] or {}
table.insert(weapons[ingot.name], {
facility = result.facility,
level = result.level,
ingot = ingot,
pole = pole,
name = result.output[1].name,
xp = result.xp
})
end
return weapons
Line 164 ⟶ 175:
local p = {}
 
function p.ingots(frame)
return table.concat(lookup_ingots(frame.args.profession).order, ',')
end
 
Line 173 ⟶ 184:
 
function p._main(args)
local profession = args.profession
 
local current_xp = tonumber(args.current_xp) or 0
local current_lvl
Line 200 ⟶ 213:
buying_poles = not (buying_logs or chopping_logs)
 
local ingot = lookup_ingots(profession).recipes[args.ingot]
 
local result = mw.html.create()
Line 223 ⟶ 236:
tbl
:tag('tr')
:th(skillclickpic('Miner')):done(){
Blacksmith = 'Miner',
:th{ 'Ore', attr = { colspan = '3' } }:done()
Stonemason = 'Miner',
:th{ 'Ingot', attr = { colspan = '2' } }:done()
Bonewright = 'Gatherer'
})[profession])):done()
:th{ ({
Blacksmith = 'Ore',
Stonemason = 'Rock',
Bonewright = 'Bone'
:th{ 'Ore'})[profession], attr = { colspan = '3' } }:done()
:th{ ({
Blacksmith = 'Ingot',
Stonemason = 'Etched',
Bonewright = 'Brewed'
:th{ 'Ingot'})[profession], attr = { colspan = '2' } }:done()
:IF(chopping_logs)
:th(skillclickpic('Woodcutter')):done()
Line 234 ⟶ 259:
:END()
:th{ 'Pole', attr = { colspan = '3' } }:done()
:th(skillclickpic('Blacksmith'profession)):done()
:th{ 'Product', attr = { colspan = '3' } }:done()
:th{ 'Cost', attr = { colspan = '10' } }:done()
:done()
 
for _, weapon in ipairs(lookup_weapons(profession)[ingot.ingot]) do
if not ingot.xp then
tbl
:tr()
:td{
'Missing XP for smeltingpreparing [[' .. ingot.ingot .. ']]; Please [' .. tostring(mw.uri.fullUrl(ingot.ingot, 'action=edit&section=1')) .. ' edit the page] to add the experience earned (after |exp =)',
attr = { colspan = colspan }
}
697

edits