Module:Sandbox/User:Alsang: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
No edit summary |
(Replaced content with "local p = {} function p.main() return end return p") Tag: Replaced |
||
(57 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
p = {} |
local p = {} |
||
function p.main() |
function p.main() |
||
return nil |
|||
end |
|||
return |
|||
function p.stone() |
|||
return p.makeTable('stone') |
|||
end |
|||
function p.metal() |
|||
return p.makeTable('metal') |
|||
end |
|||
function p.bone() |
|||
return p.makeTable('bone') |
|||
end |
|||
function p.makeTable(args) |
|||
local variants = {'basic','moderate','fine','strong','superior','perfect'} |
|||
local variants2 = {'Basic','Moderate','Fine','Strong','Superior','Perfect'} |
|||
local weaponsStone = { |
|||
'Hammerfist', |
|||
'Throwing Stones', |
|||
'Stone Slab Shield', |
|||
'Stone Mace', |
|||
'Stone Discs', |
|||
'War Hammer', |
|||
'Bolas', |
|||
'Stone Chunk Shield', |
|||
'Double Headed Hammer', |
|||
'Throwing Clubs', |
|||
'Great Stone Mace', |
|||
' Polished Stone Shield', |
|||
'Throwing Hammers', |
|||
'Great Hammer', |
|||
'Sling'} |
|||
local weaponsMetal = { |
|||
'Rapier ', |
|||
'Throwing Twinblades', |
|||
'Metal Kite Shield', |
|||
'Flanged Mace', |
|||
'Throwing Rings', |
|||
'Shortsword', |
|||
'Metal Javelins', |
|||
'Metal Heater Shield', |
|||
'Longsword', |
|||
'Throwing Knives', |
|||
'Broadsword', |
|||
'Metal Buckler', |
|||
'Throwing Axes', |
|||
'Battleaxe', |
|||
'Metal Bow'} |
|||
local weaponsBone = { |
|||
'Truncheon', |
|||
'Blowpipe', |
|||
'Wooden Round Shield', |
|||
'Cudgel', |
|||
'Javelins', |
|||
'Club', |
|||
'Light Crossbow', |
|||
'Wooden Square Shield', |
|||
'Quarterstaff', |
|||
'Recurve Bow', |
|||
'Spear', |
|||
'Wooden Hexagon Shield', |
|||
'Longbow', |
|||
'Poleaxe', |
|||
'Heavy Crossbow'} |
|||
if args=='stone' then |
|||
weapons = weaponsStone |
|||
elseif args=='metal' then |
|||
weapons = weaponsMetal |
|||
elseif args=='bone' then |
|||
weapons = weaponsBone |
|||
else |
|||
return nil |
|||
end |
|||
local allWeapons = {} |
|||
for j,wep in ipairs(weapons) do |
|||
table.insert(allWeapons,{page='[[' .. wep .. ']]'}) |
|||
end |
|||
for i,var in ipairs(variants) do |
|||
for j,wep in ipairs(weapons) do |
|||
table.insert(allWeapons,{page='[[' .. wep .. ' (' .. var .. ')]]',wrongPage1='[[' .. wep .. ' (' .. variants2[i] .. ')]]',wrongPage2='[[' .. variants2[i] .. ' ' .. wep .. ']]'}) |
|||
end |
|||
end |
|||
for i,item in ipairs(allWeapons) do |
|||
local query = mw.smw.ask(item.page .. '|?Name #- = data|mainlabel=-') |
|||
if type(query)=='table' then |
|||
item.item = query[1].data |
|||
end |
|||
local query = mw.smw.ask(item.page .. '|?Uses facility #- = data|mainlabel=-') |
|||
if type(query)=='table' then |
|||
item.facility = query[1].data |
|||
end |
|||
end |
|||
local out = mw.html.create('table') |
|||
:addClass('wikitable sortable') |
|||
:tag('tr') |
|||
:tag('th') |
|||
:wikitext('Name of page') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('Item on page') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('Recipe Facility') |
|||
:done() |
|||
:tag('th') |
|||
:wikitext('Incorrect page names') |
|||
:done() |
|||
:done() |
|||
for i,item in ipairs(allWeapons) do |
|||
local row = out:tag('tr') |
|||
:tag('td') |
|||
:wikitext(item.page) |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(item.item) |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(item.facility) |
|||
:done() |
|||
:tag('td') |
|||
:wikitext(item.wrongPage1) |
|||
:wikitext('<br>') |
|||
:wikitext(item.wrongPage2) |
|||
:done() |
|||
:done() |
|||
:done() |
|||
end |
|||
return out |
|||
end |
end |
Latest revision as of 12:51, 6 January 2025
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.