Module:Sandbox/User:Alsang: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
Tag: Undo |
No edit summary |
||
(18 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
require('strict') |
|||
require('Module:Mw.html extension') |
|||
local editbutton = require('Module:Edit button') |
|||
local edit = editbutton("'''?''' (edit)") |
|||
local hc = require('Module:Param Parse').has_content |
|||
local yn = require('Module:Yesno') |
|||
local qty = require('Module:Quantity box')._main |
|||
local pcp = require('Module:Profession clickpic')._main |
|||
local currency = require('Module:Currency') |
|||
local album_xp_data = mw.loadData('Module:Experience/data').album |
|||
local lang = mw.language.getContentLanguage() |
|||
local tooltip = require('Module:Tooltip') |
|||
local p = {} |
local p = {} |
||
function p. |
function p.minerPages() |
||
local args = frame:getParent().args |
|||
local albumxp = album_xp_data[tonumber(args.level)] |
|||
local query = { |
|||
if albumxp then |
|||
'[[Variant of::Flint||Andesite||Granite||Basalt||Deathstone||Iron Ore||Cabranese Ore||Adathril Ore||Flantium Ore||Mine Cart Work]]', |
|||
albumxp = lang:formatNum(albumxp)..' xp' |
|||
'? #- = name', |
|||
end |
|||
'?Profession Level A = level', |
|||
'?Variant of = variant', |
|||
'sort = Variant of,Profession Level A', |
|||
'limit = 500' |
|||
} |
|||
local results = mw.smw.ask(query) |
|||
for _,page in ipairs(results) do |
|||
--Checks if the recipe has been flagged as passive, defaults to no. |
|||
if string.find(page.name,'Mine') then |
|||
local passive = yn(args.passive or 'no', false) |
|||
page.node = page.name |
|||
local quant = 1 |
|||
if passive then |
|||
quant = 0.005 |
|||
end |
|||
local function exparg(xp) |
|||
if hc(xp) then |
|||
return qty(xp) |
|||
else |
else |
||
page.node = page.name .. ' (skill node)' |
|||
return qty(0)..edit..'[[Category:Needs experience info]]' |
|||
end |
end |
||
local result = mw.smw.ask('[['..page.node..']]|?Activity JSON = data') |
|||
end |
|||
page.JSON = (result and result[1] and result[1].data) or '' |
|||
if type(page.JSON)=='table' then |
|||
local function levelarg(profession, level) |
|||
page.JSON = table.concat(page.JSON,'<br>') |
|||
if hc(profession) and hc(level) then |
|||
return pcp(profession, level) |
|||
else |
|||
return edit..'[[Category:Needs level info]]' |
|||
end |
end |
||
end |
end |
||
local function durationarg(duration) |
|||
if hc(duration) then |
|||
return duration..' seconds' |
|||
else |
|||
return edit..'[[Category:Needs duration info]]' |
|||
end |
|||
end |
|||
local smw_properties = { |
|||
['Skill node name'] = args.name, |
|||
['Uses profession'] = args.profession, |
|||
['Profession level'] = args.level, |
|||
['Activity XP'] = args.xp, |
|||
['Activity album XP'] = album_xp_data[tonumber(args.level)], |
|||
['Activity KP'] = args.kp, |
|||
['Activity duration'] = args.duration, |
|||
['Activity coins'] = args.coins, |
|||
['Activity input'] = args.input, |
|||
['Activity container'] = args.container, |
|||
-- straight copy from Infobox Recipe, its good to have a standard format |
|||
['Activity JSON'] = mw.text.jsonEncode({test = true}) |
|||
} |
|||
mw.smw.set(smw_properties) |
|||
local out = mw.html.create('table') |
local out = mw.html.create('table') |
||
:addClass('wikitable') |
:addClass('wikitable sortable') |
||
:tag('tr') |
:tag('tr') |
||
:tag('th') |
:tag('th') |
||
: |
:wikitext('Variant') |
||
:wikitext(args.name) |
|||
:done() |
:done() |
||
:done() |
|||
:tag('tr') |
|||
:tag('th') |
:tag('th') |
||
:wikitext('Level |
:wikitext('Level') |
||
:done() |
:done() |
||
:tag(' |
:tag('th') |
||
:wikitext( |
:wikitext('Page') |
||
:done() |
:done() |
||
:done() |
|||
:tag('tr') |
|||
:tag('th') |
:tag('th') |
||
: |
:wikitext('Node') |
||
:wikitext('[[File:Passive small icon.png|20x20px|link=Passive Activity]] [['..args.profession..'|'..args.profession..' XP]] ') |
|||
:node(tooltip._span{ 'passive' }) |
|||
:node(tooltip._div{ name = 'passive', content = 'Passive activities give reduced experience when a players level is high enough to perform a new passive activity for that profession. The number shown here is the full experience.' }) |
|||
:ELSE() |
|||
:wikitext('[['..args.profession..'|'..args.profession..' XP]]') |
|||
:END() |
|||
:done() |
:done() |
||
:tag(' |
:tag('th') |
||
:wikitext( |
:wikitext('Node JSON') |
||
:done() |
:done() |
||
:done() |
:done() |
||
:tag('tr') |
|||
for i, item in ipairs(results) do |
|||
:tag('th') |
|||
local row = out:tag('tr') |
|||
:wikitext('[[Album|Album XP]]') |
|||
--level |
|||
:tag('td') |
|||
:wikitext(item.variant) |
|||
:done() |
:done() |
||
:tag('td') |
:tag('td') |
||
:wikitext( |
:wikitext(item.level) |
||
:done() |
:done() |
||
: |
:tag('td') |
||
:wikitext('[['..item.name..']]') |
|||
:tag('tr') |
|||
:tag('th') |
|||
:wikitext('Duration') |
|||
:done() |
:done() |
||
:tag('td') |
:tag('td') |
||
:wikitext( |
:wikitext('[['..item.node..']]') |
||
:done() |
:done() |
||
: |
:tag('td') |
||
:wikitext(item.JSON) |
|||
if hc(args.respawn) then |
|||
out |
|||
:tag('tr') |
|||
:tag('th') |
|||
:wikitext('Respawn time') |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(durationarg(args.respawn)) |
|||
:done() |
|||
:done() |
|||
end |
|||
if hc(args.tool) then |
|||
out |
|||
:tag('tr') |
|||
:tag('th') |
|||
:wikitext('Required tool') |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(args.tool) |
|||
:done() |
|||
:done() |
|||
end |
|||
if hc(args.input) then |
|||
out |
|||
:tag('tr') |
|||
:tag('th') |
|||
:wikitext('Required input') |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(args.input) |
|||
:done() |
|||
:done() |
|||
end |
|||
if hc(args.container) then |
|||
out |
|||
:tag('tr') |
|||
:tag('th') |
|||
:wikitext('Required container') |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(args.container) |
|||
:done() |
|||
:done() |
|||
end |
|||
if hc(args.coins) then |
|||
out |
|||
:tag('tr') |
|||
:tag('th') |
|||
:wikitext('Coins') |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(currency.parse(args.coins)) |
|||
:done() |
|||
:done() |
:done() |
||
end |
end |
||
return out |
return out |
||
end |
end |
||
Latest revision as of 19:04, 20 December 2024
Module documentation
This documentation is transcluded from Module:Sandbox/User:Alsang/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Sandbox/User:Alsang/doc. [edit]
Module:Sandbox/User:Alsang's function main is invoked by Template:Sandbox/User:Alsang.
local p = {}
function p.minerPages()
local query = {
'[[Variant of::Flint||Andesite||Granite||Basalt||Deathstone||Iron Ore||Cabranese Ore||Adathril Ore||Flantium Ore||Mine Cart Work]]',
'? #- = name',
'?Profession Level A = level',
'?Variant of = variant',
'sort = Variant of,Profession Level A',
'limit = 500'
}
local results = mw.smw.ask(query)
for _,page in ipairs(results) do
if string.find(page.name,'Mine') then
page.node = page.name
else
page.node = page.name .. ' (skill node)'
end
local result = mw.smw.ask('[['..page.node..']]|?Activity JSON = data')
page.JSON = (result and result[1] and result[1].data) or ''
if type(page.JSON)=='table' then
page.JSON = table.concat(page.JSON,'<br>')
end
end
local out = mw.html.create('table')
:addClass('wikitable sortable')
:tag('tr')
:tag('th')
:wikitext('Variant')
:done()
:tag('th')
:wikitext('Level')
:done()
:tag('th')
:wikitext('Page')
:done()
:tag('th')
:wikitext('Node')
:done()
:tag('th')
:wikitext('Node JSON')
:done()
:done()
for i, item in ipairs(results) do
local row = out:tag('tr')
--level
:tag('td')
:wikitext(item.variant)
:done()
:tag('td')
:wikitext(item.level)
:done()
:tag('td')
:wikitext('[['..item.name..']]')
:done()
:tag('td')
:wikitext('[['..item.node..']]')
:done()
:tag('td')
:wikitext(item.JSON)
:done()
end
return out
end
return p