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 3: | Line 3: | ||
current_xp = 24, |
current_xp = 24, |
||
target_xp = 37, |
target_xp = 37, |
||
ingot = ' |
ingot = 'Coarse Deathstone (Etched)', |
||
profession = 'Stonemason', -- 'Bonewright'/'Stonemason'/'Blacksmith' |
|||
ore_buy = 'true', |
ore_buy = 'true', |
||
pole_buy = 'none', -- 'none'/'logs'/'pole' |
pole_buy = 'none', -- 'none'/'logs'/'pole' |
||
Line 15: | Line 16: | ||
local lang = mw.language.getContentLanguage() |
local lang = mw.language.getContentLanguage() |
||
local _ingots |
local _ingots = {} |
||
local function lookup_ingots() |
local function lookup_ingots(profession) |
||
if _ingots then |
if _ingots[profession] then |
||
return _ingots |
return _ingots[profession] |
||
end |
end |
||
_ingots = { |
_ingots[profession] = { |
||
recipes = {}, |
recipes = {}, |
||
order = {} |
order = {} |
||
} |
} |
||
for _, result in ipairs(mw.smw.ask{ |
for _, result in ipairs(mw.smw.ask{ |
||
⚫ | |||
'[[Uses facility::Goblin Smelter||Gnome Smelter]]', |
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'] = '', |
['?Recipe JSON'] = '', |
||
mainlabel = '-', |
mainlabel = '-', |
||
Line 33: | Line 38: | ||
result = mw.text.jsonDecode(result[1]) |
result = mw.text.jsonDecode(result[1]) |
||
local ingot = result.output[1].name |
local ingot = result.output[1].name |
||
_ingots.recipes[ingot] = { |
_ingots[profession].recipes[ingot] = { |
||
xp = result.xp, |
xp = result.xp, |
||
facility = result.facility, |
facility = result.facility, |
||
Line 40: | Line 45: | ||
level = result.level |
level = result.level |
||
} |
} |
||
table.insert(_ingots.order, ingot) |
table.insert(_ingots[profession].order, ingot) |
||
end |
end |
||
return _ingots |
return _ingots[profession] |
||
end |
end |
||
local function lookup_weapons() |
local function lookup_weapons(profession) |
||
local ingots = lookup_ingots() |
local ingots = lookup_ingots(profession) |
||
local weapons = {} |
local weapons = {} |
||
for _, result in ipairs(mw.smw.ask{ |
for _, result in ipairs(mw.smw.ask{ |
||
({ |
|||
'[[Uses facility::Goblin Forge||Gnome Forge]]', |
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'] = '', |
['?Recipe JSON'] = '', |
||
mainlabel = '-', |
mainlabel = '-', |
||
Line 57: | Line 66: | ||
local lvl = result['Profession Level A'] |
local lvl = result['Profession Level A'] |
||
result = mw.text.jsonDecode(result[1]) |
result = mw.text.jsonDecode(result[1]) |
||
if not result.passive and result.profession == profession then |
|||
⚫ | |||
local |
local ingot |
||
⚫ | |||
for _, material in ipairs(result.materials) do |
|||
for _, material in ipairs(result.materials) do |
|||
if ingots.recipes[material.name] then |
|||
⚫ | |||
ingot |
assert(not ingot) |
||
⚫ | |||
else |
else |
||
⚫ | |||
pole |
assert(not pole) |
||
⚫ | |||
end |
|||
end |
end |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
}) |
|||
end |
end |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
return weapons |
return weapons |
||
Line 164: | Line 175: | ||
local p = {} |
local p = {} |
||
function p.ingots() |
function p.ingots(frame) |
||
return table.concat(lookup_ingots().order, ',') |
return table.concat(lookup_ingots(frame.args.profession).order, ',') |
||
end |
end |
||
Line 173: | Line 184: | ||
function p._main(args) |
function p._main(args) |
||
local profession = args.profession |
|||
local current_xp = tonumber(args.current_xp) or 0 |
local current_xp = tonumber(args.current_xp) or 0 |
||
local current_lvl |
local current_lvl |
||
Line 200: | Line 213: | ||
buying_poles = not (buying_logs or chopping_logs) |
buying_poles = not (buying_logs or chopping_logs) |
||
local ingot = lookup_ingots().recipes[args.ingot] |
local ingot = lookup_ingots(profession).recipes[args.ingot] |
||
local result = mw.html.create() |
local result = mw.html.create() |
||
Line 223: | Line 236: | ||
tbl |
tbl |
||
:tag('tr') |
:tag('tr') |
||
:th(skillclickpic( |
:th(skillclickpic(({ |
||
Blacksmith = 'Miner', |
|||
⚫ | |||
Stonemason = 'Miner', |
|||
⚫ | |||
Bonewright = 'Gatherer' |
|||
})[profession])):done() |
|||
:th{ ({ |
|||
Blacksmith = 'Ore', |
|||
Stonemason = 'Rock', |
|||
Bonewright = 'Bone' |
|||
⚫ | |||
:th{ ({ |
|||
Blacksmith = 'Ingot', |
|||
Stonemason = 'Etched', |
|||
Bonewright = 'Brewed' |
|||
⚫ | |||
:IF(chopping_logs) |
:IF(chopping_logs) |
||
:th(skillclickpic('Woodcutter')):done() |
:th(skillclickpic('Woodcutter')):done() |
||
Line 234: | Line 259: | ||
:END() |
:END() |
||
:th{ 'Pole', attr = { colspan = '3' } }:done() |
:th{ 'Pole', attr = { colspan = '3' } }:done() |
||
:th(skillclickpic( |
:th(skillclickpic(profession)):done() |
||
:th{ 'Product', attr = { colspan = '3' } }:done() |
:th{ 'Product', attr = { colspan = '3' } }:done() |
||
:th{ 'Cost', attr = { colspan = '10' } }:done() |
:th{ 'Cost', attr = { colspan = '10' } }:done() |
||
:done() |
:done() |
||
for _, weapon in ipairs(lookup_weapons()[ingot.ingot]) do |
for _, weapon in ipairs(lookup_weapons(profession)[ingot.ingot]) do |
||
if not ingot.xp then |
if not ingot.xp then |
||
tbl |
tbl |
||
:tr() |
:tr() |
||
:td{ |
:td{ |
||
'Missing XP for |
'Missing XP for preparing [[' .. ingot.ingot .. ']]; Please [' .. tostring(mw.uri.fullUrl(ingot.ingot, 'action=edit§ion=1')) .. ' edit the page] to add the experience earned (after |exp =)', |
||
attr = { colspan = colspan } |
attr = { colspan = colspan } |
||
} |
} |