Difference between revisions of "Module:Apt"
CommanderC (talk | contribs) |
CommanderC (talk | contribs) |
||
Line 58: | Line 58: | ||
end | end | ||
− | + | function p.aptitude_chart_general(frame) | |
local data = mw.loadData('Module:Table of aptitudes') | local data = mw.loadData('Module:Table of aptitudes') | ||
+ | local skill = frame.args[1] | ||
local species = {'Human', 'Centaur', 'Demigod', 'Demonspawn', | local species = {'Human', 'Centaur', 'Demigod', 'Demonspawn', | ||
'Base Draconian', 'Deep Dwarf', 'Deep Elf', 'High Elf', | 'Base Draconian', 'Deep Dwarf', 'Deep Elf', 'High Elf', | ||
Line 65: | Line 66: | ||
'Minotaur', 'Mummy', 'Naga', 'Octopode', 'Ogre', 'Hill Orc', | 'Minotaur', 'Mummy', 'Naga', 'Octopode', 'Ogre', 'Hill Orc', | ||
'Spriggan', 'Tengu', 'Troll', 'Vampire'} | 'Spriggan', 'Tengu', 'Troll', 'Vampire'} | ||
− | local result = | + | local skills = {'Armour', 'Dodging', 'Stealth', 'Stabbing', |
− | + | 'Shields', 'Traps', 'Invocations', 'Evocations', 'Hit Points', 'Magic Points', 'Experience'} | |
+ | local result = [=[ | ||
+ | {| class="wikitable sortable" style="font-size:75%" border=1 | ||
+ | ! scope="col" | [[Species]] | ||
+ | ! scope="col" | [[Armour (skill)|Arm]] | ||
+ | ! scope="col" | [[Dodging|Ddg]] | ||
+ | ! scope="col" | [[Stealth|Sth]] | ||
+ | ! scope="col" | [[Stabbing|Stb]] | ||
+ | ! scope="col" | [[Shields (skill)|Shd]] | ||
+ | ! scope="col" | [[Traps|Trp]] | ||
+ | ! scope="col" | [[Invocations|Inv]] | ||
+ | ! scope="col" | [[Evocations|Evo]] | ||
+ | ! scope="col" | [[HP]] | ||
+ | ! scope="col" | [[MP]] | ||
+ | ! scope="col" | [[Exp]] | ||
+ | |- | ||
+ | ]=] | ||
-- constants used by sort_key | -- constants used by sort_key | ||
local a_ord = string.byte('a') | local a_ord = string.byte('a') | ||
Line 94: | Line 111: | ||
result = result .. "|}" | result = result .. "|}" | ||
return result | return result | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
function p.aptitude_chart_combat(frame) | function p.aptitude_chart_combat(frame) | ||
+ | local data = mw.loadData('Module:Table of aptitudes') | ||
+ | local skill = frame.args[1] | ||
+ | local species = {'Human', 'Centaur', 'Demigod', 'Demonspawn', | ||
+ | 'Base Draconian', 'Deep Dwarf', 'Deep Elf', 'High Elf', | ||
+ | 'Sludge Elf', 'Felid', 'Ghoul', 'Halfling', 'Kobold', 'Merfolk', | ||
+ | 'Minotaur', 'Mummy', 'Naga', 'Octopode', 'Ogre', 'Hill Orc', | ||
+ | 'Spriggan', 'Tengu', 'Troll', 'Vampire'} | ||
local skills = {'Fighting', 'Short Blades', 'Long Blades', 'Maces Flails', | local skills = {'Fighting', 'Short Blades', 'Long Blades', 'Maces Flails', | ||
'Axes', 'Polearms', 'Staves', 'Unarmed Combat', 'Throwing', 'Slings', 'Bows', 'Crossbows'} | 'Axes', 'Polearms', 'Staves', 'Unarmed Combat', 'Throwing', 'Slings', 'Bows', 'Crossbows'} | ||
− | local | + | local result = [=[ |
{| class="wikitable sortable" style="font-size:75%" border=1 | {| class="wikitable sortable" style="font-size:75%" border=1 | ||
! scope="col" | [[Species]] | ! scope="col" | [[Species]] | ||
Line 138: | Line 140: | ||
|- | |- | ||
]=] | ]=] | ||
− | return | + | -- constants used by sort_key |
+ | local a_ord = string.byte('a') | ||
+ | local z_ord = string.byte('z') | ||
+ | local aa_ord = string.byte('A') | ||
+ | -- generates the table keys | ||
+ | function sort_key(i) | ||
+ | local result | ||
+ | if i > z_ord - a_ord then | ||
+ | i = i - (z_ord - a_ord) - 1 | ||
+ | result = '!' .. string.char(aa_ord + i) | ||
+ | else | ||
+ | result = '"' .. string.char(a_ord + i) | ||
+ | end | ||
+ | return result | ||
+ | end | ||
+ | |||
+ | local i = 0 | ||
+ | for _, sp in ipairs(species) do | ||
+ | result = result .. '|<span style="display:none;">' .. sort_key(i) .. '</span>' .. sp .. "\n" | ||
+ | for _,sk in ipairs(skills) do | ||
+ | result = result .. "||" .. data[sp][sk] .. "\n" | ||
+ | end | ||
+ | result = result .. "|-\n" | ||
+ | i = i + 1 | ||
+ | end | ||
+ | result = result .. "|}" | ||
+ | return result | ||
end | end | ||
function p.aptitude_chart_magic(frame) | function p.aptitude_chart_magic(frame) | ||
+ | local data = mw.loadData('Module:Table of aptitudes') | ||
+ | local skill = frame.args[1] | ||
+ | local species = {'Human', 'Centaur', 'Demigod', 'Demonspawn', | ||
+ | 'Base Draconian', 'Deep Dwarf', 'Deep Elf', 'High Elf', | ||
+ | 'Sludge Elf', 'Felid', 'Ghoul', 'Halfling', 'Kobold', 'Merfolk', | ||
+ | 'Minotaur', 'Mummy', 'Naga', 'Octopode', 'Ogre', 'Hill Orc', | ||
+ | 'Spriggan', 'Tengu', 'Troll', 'Vampire'} | ||
local skills = {'Spellcasting', 'Conjurations', 'Hexes', 'Charms', | local skills = {'Spellcasting', 'Conjurations', 'Hexes', 'Charms', | ||
'Summonings', 'Necromancy', 'Translocations', 'Transmutations', | 'Summonings', 'Necromancy', 'Translocations', 'Transmutations', | ||
'Fire Magic', 'Ice Magic', 'Air Magic', 'Earth Magic', 'Poison Magic'} | 'Fire Magic', 'Ice Magic', 'Air Magic', 'Earth Magic', 'Poison Magic'} | ||
− | local | + | local result = [=[ |
{| class="wikitable sortable" style="font-size:75%" border=1 | {| class="wikitable sortable" style="font-size:75%" border=1 | ||
! scope="col" | [[Species]] | ! scope="col" | [[Species]] | ||
Line 163: | Line 198: | ||
|- | |- | ||
]=] | ]=] | ||
− | return | + | -- constants used by sort_key |
+ | local a_ord = string.byte('a') | ||
+ | local z_ord = string.byte('z') | ||
+ | local aa_ord = string.byte('A') | ||
+ | -- generates the table keys | ||
+ | function sort_key(i) | ||
+ | local result | ||
+ | if i > z_ord - a_ord then | ||
+ | i = i - (z_ord - a_ord) - 1 | ||
+ | result = '!' .. string.char(aa_ord + i) | ||
+ | else | ||
+ | result = '"' .. string.char(a_ord + i) | ||
+ | end | ||
+ | return result | ||
+ | end | ||
+ | |||
+ | local i = 0 | ||
+ | for _, sp in ipairs(species) do | ||
+ | result = result .. '|<span style="display:none;">' .. sort_key(i) .. '</span>' .. sp .. "\n" | ||
+ | for _,sk in ipairs(skills) do | ||
+ | result = result .. "||" .. data[sp][sk] .. "\n" | ||
+ | end | ||
+ | result = result .. "|-\n" | ||
+ | i = i + 1 | ||
+ | end | ||
+ | result = result .. "|}" | ||
+ | return result | ||
end | end | ||
return p | return p |
Revision as of 23:11, 18 September 2013
Documentation for this module may be created at Module:Apt/doc
local p = {} function p.aptitude(frame) local data = mw.loadData('Module:Table of aptitudes') local sp = frame.args[1] local sk = frame.args[2] if not sp or not sk then return "" end if sp == "Draconian" then sp = "Base Draconian" end return data[sp][sk] end function p.skill_table(frame) local data = mw.loadData('Module:Table of aptitudes') local skill = frame.args[1] local species = {'Human', 'Centaur', 'Demigod', 'Demonspawn', 'Base Draconian', 'Deep Dwarf', 'Deep Elf', 'High Elf', 'Sludge Elf', 'Felid', 'Ghoul', 'Halfling', 'Kobold', 'Merfolk', 'Minotaur', 'Mummy', 'Naga', 'Octopode', 'Ogre', 'Hill Orc', 'Spriggan', 'Tengu', 'Troll', 'Vampire'} local result = [=[ {| class="wikitable" border="1" |- |'''[[Human|Hu]]''' |'''[[Centaur|Ce]]''' |'''[[Demigod|Dg]]''' |'''[[Demonspawn|Ds]]''' |'''[[Draconian|Dr]]''' |'''[[Deep Dwarf|DD]] |'''[[Deep Elf|DE]]''' |'''[[High Elf|HE]]''' |'''[[Sludge Elf|SE]]''' |'''[[Felid|Fe]]''' |'''[[Ghoul|Gh]]''' |'''[[Halfling|Ha]]''' |'''[[Kobold|Ko]]''' |'''[[Merfolk|Mf]]''' |'''[[Minotaur|Mi]]''' |'''[[Mummy|Mu]]''' |'''[[Naga|Na]]''' |'''[[Octopode|Op]]''' |'''[[Ogre|Og]]''' |'''[[Hill Orc|HO]]''' |'''[[Spriggan|Sp]]''' |'''[[Tengu|Te]]''' |'''[[Troll|Tr]]''' |'''[[Vampire|Vp]]''' |- ]=] for _, sp in ipairs(species) do result = result .. "| " .. data[sp][skill] .. "\n" end result = result .. "|}" return result end function p.aptitude_chart_general(frame) local data = mw.loadData('Module:Table of aptitudes') local skill = frame.args[1] local species = {'Human', 'Centaur', 'Demigod', 'Demonspawn', 'Base Draconian', 'Deep Dwarf', 'Deep Elf', 'High Elf', 'Sludge Elf', 'Felid', 'Ghoul', 'Halfling', 'Kobold', 'Merfolk', 'Minotaur', 'Mummy', 'Naga', 'Octopode', 'Ogre', 'Hill Orc', 'Spriggan', 'Tengu', 'Troll', 'Vampire'} local skills = {'Armour', 'Dodging', 'Stealth', 'Stabbing', 'Shields', 'Traps', 'Invocations', 'Evocations', 'Hit Points', 'Magic Points', 'Experience'} local result = [=[ {| class="wikitable sortable" style="font-size:75%" border=1 ! scope="col" | [[Species]] ! scope="col" | [[Armour (skill)|Arm]] ! scope="col" | [[Dodging|Ddg]] ! scope="col" | [[Stealth|Sth]] ! scope="col" | [[Stabbing|Stb]] ! scope="col" | [[Shields (skill)|Shd]] ! scope="col" | [[Traps|Trp]] ! scope="col" | [[Invocations|Inv]] ! scope="col" | [[Evocations|Evo]] ! scope="col" | [[HP]] ! scope="col" | [[MP]] ! scope="col" | [[Exp]] |- ]=] -- constants used by sort_key local a_ord = string.byte('a') local z_ord = string.byte('z') local aa_ord = string.byte('A') -- generates the table keys function sort_key(i) local result if i > z_ord - a_ord then i = i - (z_ord - a_ord) - 1 result = '!' .. string.char(aa_ord + i) else result = '"' .. string.char(a_ord + i) end return result end local i = 0 for _, sp in ipairs(species) do result = result .. '|<span style="display:none;">' .. sort_key(i) .. '</span>' .. sp .. "\n" for _,sk in ipairs(skills) do result = result .. "||" .. data[sp][sk] .. "\n" end result = result .. "|-\n" i = i + 1 end result = result .. "|}" return result end function p.aptitude_chart_combat(frame) local data = mw.loadData('Module:Table of aptitudes') local skill = frame.args[1] local species = {'Human', 'Centaur', 'Demigod', 'Demonspawn', 'Base Draconian', 'Deep Dwarf', 'Deep Elf', 'High Elf', 'Sludge Elf', 'Felid', 'Ghoul', 'Halfling', 'Kobold', 'Merfolk', 'Minotaur', 'Mummy', 'Naga', 'Octopode', 'Ogre', 'Hill Orc', 'Spriggan', 'Tengu', 'Troll', 'Vampire'} local skills = {'Fighting', 'Short Blades', 'Long Blades', 'Maces Flails', 'Axes', 'Polearms', 'Staves', 'Unarmed Combat', 'Throwing', 'Slings', 'Bows', 'Crossbows'} local result = [=[ {| class="wikitable sortable" style="font-size:75%" border=1 ! scope="col" | [[Species]] ! scope="col" | [[Fighting|Fgt]] ! scope="col" | [[Short Blades|SBl]] ! scope="col" | [[Long Blades|LBl]] ! scope="col" | [[Maces & Flails|M&F]] ! scope="col" | [[Axes|Axs]] ! scope="col" | [[Polearms|Pla]] ! scope="col" | [[Staves|Stv]] ! scope="col" | [[Unarmed Combat|UC]] ! scope="col" | [[Throwing|Thr]] ! scope="col" | [[Slings|Slg]] ! scope="col" | [[Bows|Bws]] ! scope="col" | [[Crossbows|Crb]] |- ]=] -- constants used by sort_key local a_ord = string.byte('a') local z_ord = string.byte('z') local aa_ord = string.byte('A') -- generates the table keys function sort_key(i) local result if i > z_ord - a_ord then i = i - (z_ord - a_ord) - 1 result = '!' .. string.char(aa_ord + i) else result = '"' .. string.char(a_ord + i) end return result end local i = 0 for _, sp in ipairs(species) do result = result .. '|<span style="display:none;">' .. sort_key(i) .. '</span>' .. sp .. "\n" for _,sk in ipairs(skills) do result = result .. "||" .. data[sp][sk] .. "\n" end result = result .. "|-\n" i = i + 1 end result = result .. "|}" return result end function p.aptitude_chart_magic(frame) local data = mw.loadData('Module:Table of aptitudes') local skill = frame.args[1] local species = {'Human', 'Centaur', 'Demigod', 'Demonspawn', 'Base Draconian', 'Deep Dwarf', 'Deep Elf', 'High Elf', 'Sludge Elf', 'Felid', 'Ghoul', 'Halfling', 'Kobold', 'Merfolk', 'Minotaur', 'Mummy', 'Naga', 'Octopode', 'Ogre', 'Hill Orc', 'Spriggan', 'Tengu', 'Troll', 'Vampire'} local skills = {'Spellcasting', 'Conjurations', 'Hexes', 'Charms', 'Summonings', 'Necromancy', 'Translocations', 'Transmutations', 'Fire Magic', 'Ice Magic', 'Air Magic', 'Earth Magic', 'Poison Magic'} local result = [=[ {| class="wikitable sortable" style="font-size:75%" border=1 ! scope="col" | [[Species]] ! scope="col" | [[Spellcasting|Spc]] ! scope="col" | [[Conjurations|Coj]] ! scope="col" | [[Hexes|Hex]] ! scope="col" | [[Charms|Cha]] ! scope="col" | [[Summonings|Sum]] ! scope="col" | [[Necromancy|Nec]] ! scope="col" | [[Translocations|Trl]] ! scope="col" | [[Transmutations|Trm]] ! scope="col" | [[Fire Magic|Fir]] ! scope="col" | [[Ice Magic|Ice]] ! scope="col" | [[Air Magic|Air]] ! scope="col" | [[Earth Magic|Ear]] ! scope="col" | [[Poison Magic|Poi]] |- ]=] -- constants used by sort_key local a_ord = string.byte('a') local z_ord = string.byte('z') local aa_ord = string.byte('A') -- generates the table keys function sort_key(i) local result if i > z_ord - a_ord then i = i - (z_ord - a_ord) - 1 result = '!' .. string.char(aa_ord + i) else result = '"' .. string.char(a_ord + i) end return result end local i = 0 for _, sp in ipairs(species) do result = result .. '|<span style="display:none;">' .. sort_key(i) .. '</span>' .. sp .. "\n" for _,sk in ipairs(skills) do result = result .. "||" .. data[sp][sk] .. "\n" end result = result .. "|-\n" i = i + 1 end result = result .. "|}" return result end return p