Editing Module:Sandbox/User:Artoire/1

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 3: Line 3:
current_xp = 24,
current_xp = 24,
target_xp = 37,
target_xp = 37,
ingot = 'Coarse Deathstone (Etched)',
ingot = 'Maloic Adathril Ingot',
profession = 'Stonemason', -- 'Bonewright'/'Stonemason'/'Blacksmith'
ore_buy = 'true',
ore_buy = 'true',
pole_buy = 'none', -- 'none'/'logs'/'pole'
pole_buy = 'none', -- 'none'/'logs'/'pole'
Line 16: Line 15:
local lang = mw.language.getContentLanguage()
local lang = mw.language.getContentLanguage()


local _ingots = {}
local _ingots
local function lookup_ingots(profession)
local function lookup_ingots()
if _ingots[profession] then
if _ingots then
return _ingots[profession]
return _ingots
end
end
_ingots[profession] = {
_ingots = {
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 38: Line 33:
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[profession].recipes[ingot] = {
_ingots.recipes[ingot] = {
xp = result.xp,
xp = result.xp,
facility = result.facility,
facility = result.facility,
Line 45: Line 40:
level = result.level
level = result.level
}
}
table.insert(_ingots[profession].order, ingot)
table.insert(_ingots.order, ingot)
end
end
return _ingots[profession]
return _ingots
end
end


local function lookup_weapons(profession)
local function lookup_weapons()
local ingots = lookup_ingots(profession)
local ingots = lookup_ingots()
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 66: Line 57:
local lvl = result['Profession Level A']
local lvl = result['Profession Level A']
result = mw.text.jsonDecode(result[1])
result = mw.text.jsonDecode(result[1])
local ingot
if not result.passive and result.profession == profession then
local ingot
local pole
for _, material in ipairs(result.materials) do
local pole
for _, material in ipairs(result.materials) do
if ingots.recipes[material.name] then
assert(not ingot)
if ingots.recipes[material.name] then
assert(not ingot)
ingot = material
else
ingot = material
assert(not pole)
else
assert(not pole)
pole = material
pole = material
end
end
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
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
end
return weapons
return weapons
Line 175: Line 164:
local p = {}
local p = {}


function p.ingots(frame)
function p.ingots()
return table.concat(lookup_ingots(frame.args.profession).order, ',')
return table.concat(lookup_ingots().order, ',')
end
end


Line 184: Line 173:


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 213: Line 200:
buying_poles = not (buying_logs or chopping_logs)
buying_poles = not (buying_logs or chopping_logs)


local ingot = lookup_ingots(profession).recipes[args.ingot]
local ingot = lookup_ingots().recipes[args.ingot]


local result = mw.html.create()
local result = mw.html.create()
Line 236: Line 223:
tbl
tbl
:tag('tr')
:tag('tr')
:th(skillclickpic(({
:th(skillclickpic('Miner')):done()
:th{ 'Ore', attr = { colspan = '3' } }:done()
Blacksmith = 'Miner',
:th{ 'Ingot', attr = { colspan = '2' } }:done()
Stonemason = 'Miner',
Bonewright = 'Gatherer'
})[profession])):done()
:th{ ({
Blacksmith = 'Ore',
Stonemason = 'Rock',
Bonewright = 'Bone'
})[profession], attr = { colspan = '3' } }:done()
:th{ ({
Blacksmith = 'Ingot',
Stonemason = 'Etched',
Bonewright = 'Brewed'
})[profession], attr = { colspan = '2' } }:done()
:IF(chopping_logs)
:IF(chopping_logs)
:th(skillclickpic('Woodcutter')):done()
:th(skillclickpic('Woodcutter')):done()
Line 259: Line 234:
:END()
:END()
:th{ 'Pole', attr = { colspan = '3' } }:done()
:th{ 'Pole', attr = { colspan = '3' } }:done()
:th(skillclickpic(profession)):done()
:th(skillclickpic('Blacksmith')):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(profession)[ingot.ingot]) do
for _, weapon in ipairs(lookup_weapons()[ingot.ingot]) do
if not ingot.xp then
if not ingot.xp then
tbl
tbl
:tr()
:tr()
:td{
:td{
'Missing XP for preparing [[' .. ingot.ingot .. ']]; Please [' .. tostring(mw.uri.fullUrl(ingot.ingot, 'action=edit&section=1')) .. ' edit the page] to add the experience earned (after |exp =)',
'Missing XP for smelting [[' .. 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 }
attr = { colspan = colspan }
}
}
Please note that all contributions to Brighter Shores Wiki are considered to be released under the CC BY-NC-SA 3.0 (see Brighter Shores:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template

Template used on this page: