17,097
edits
(Clone live module) |
(0.21 testing) |
||
Line 2: | Line 2: | ||
local MonsterData = mw.loadData('Module:Monsters/data') | local MonsterData = mw.loadData('Module:Monsters/data') | ||
local ItemData = mw.loadData('Module: | local ItemData = mw.loadData('Module:AuronTest/data') | ||
local SkillData = mw.loadData('Module:Skills/data') | local SkillData = mw.loadData('Module:Skills/data') | ||
local Constants = require('Module:Constants') | |||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local Magic = require('Module:Magic') | local Magic = require('Module:Magic') | ||
local Areas = require('Module:CombatAreas') | local Areas = require('Module:CombatAreas') | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local Items = require('Module: | local Items = require('Module:AuronTest') | ||
local Shop = require('Module:Shop') | local Shop = require('Module:Shop') | ||
local Monsters = require('Module:Monsters') | local Monsters = require('Module:Monsters') | ||
Line 34: | Line 34: | ||
local qty = nil | local qty = nil | ||
local req = nil | local req = nil | ||
local tables = {} | local tables = {} | ||
Line 82: | Line 81: | ||
skill = 'Herblore' | skill = 'Herblore' | ||
req = item.herbloreReq | req = item.herbloreReq | ||
--Currently using ' | --Currently using 'masteryID' as shorthand to find details, could be a better method | ||
local potionID = item. | local potionID = item.masteryID[2] | ||
local potionData = SkillData.Herblore.ItemData[potionID + 1] | local potionData = SkillData.Herblore.ItemData[potionID + 1] | ||
lvl = potionData.herbloreLevel | lvl = potionData.herbloreLevel | ||
Line 90: | Line 89: | ||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time)) | ||
end | end | ||
if item. | if item.masteryID ~= nil and item.masteryID[1] == 4 then | ||
skill = 'Mining' | skill = 'Mining' | ||
lvl = SkillData.Mining.Rocks[item.masteryID[2] + 1].level | lvl = SkillData.Mining.Rocks[item.masteryID[2] + 1].level | ||
Line 184: | Line 183: | ||
local item = Items.getItemByID(cost.id) | local item = Items.getItemByID(cost.id) | ||
if item.type ~= 'Shard' then | if item.type ~= 'Shard' then | ||
local sellPrice = item.sellsFor | local sellPrice = math.max(item.sellsFor, 20) | ||
table.insert(nonShardArray, Icons.Icon({item.name, type='item', notext=true, qty=math.max(1, math.floor(recipeGPCost / sellPrice))})) | table.insert(nonShardArray, Icons.Icon({item.name, type='item', notext=true, qty=math.max(1, math.floor(recipeGPCost / sellPrice))})) | ||
end | end | ||
Line 208: | Line 206: | ||
table.insert(tables, p.buildAltMagicTable('Just Learning')) | table.insert(tables, p.buildAltMagicTable('Just Learning')) | ||
elseif item.name == 'Bones' then | elseif item.name == 'Bones' then | ||
table.insert(tables, p.buildAltMagicTable('Bone Offering')) | table.insert(tables, p.buildAltMagicTable('Bone Offering')) | ||
elseif item.name == 'Holy Dust' then | elseif item.name == 'Holy Dust' then | ||
table.insert(tables, p.buildAltMagicTable('Blessed Offering')) | table.insert(tables, p.buildAltMagicTable('Blessed Offering')) | ||
Line 222: | Line 220: | ||
function p.buildAltMagicTable(spellName) | function p.buildAltMagicTable(spellName) | ||
local spell = Magic.getSpell(spellName, 'AltMagic') | local spell = Magic.getSpell(spellName, 'AltMagic') | ||
local | local resultPart = {} | ||
table.insert(resultPart, '{|class="wikitable"\r\n|-') | |||
table.insert(resultPart, '\r\n!colspan="2"|'..Icons.Icon({spell.name, type='spell'})) | |||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Requirements') | |||
table.insert(resultPart, '\r\n|'..Icons._SkillReq('Magic', spell.magicLevelRequired)) | |||
-- 1 means select any item. 0 would mean Superheat, but that's handled elsewhere | -- 1 means select any item. 0 would mean Superheat, but that's handled elsewhere | ||
-- -1 means no item is needed, so hide this section | -- -1 means no item is needed, so hide this section | ||
if spell.selectItem == 1 then | if spell.selectItem == 1 then | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Materials') | |||
table.insert(resultPart, '\r\n|1 of any item') | |||
end | end | ||
--Add runes | --Add runes | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Runes\r\n|') | |||
for i, req in pairs(spell.runesRequired) do | for i, req in pairs(spell.runesRequired) do | ||
local rune = Items.getItemByID(req.id) | local rune = Items.getItemByID(req.id) | ||
if i > 1 then | if i > 1 then table.insert(resultPart, ', ') end | ||
table.insert(resultPart, Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})) | |||
end | end | ||
if spell.runesRequiredAlt ~= nil and Shared.tableCount(spell.runesRequired) ~= Shared.tableCount(spell.runesRequiredAlt) then | if spell.runesRequiredAlt ~= nil and Shared.tableCount(spell.runesRequired) ~= Shared.tableCount(spell.runesRequiredAlt) then | ||
table.insert(resultPart, "<br/>'''OR'''<br/>") | |||
for i, req in pairs(spell.runesRequiredAlt) do | for i, req in pairs(spell.runesRequiredAlt) do | ||
local rune = Items.getItemByID(req.id) | local rune = Items.getItemByID(req.id) | ||
if i > 1 then | if i > 1 then table.insert(resultPart, ', ') end | ||
table.insert(resultPart, Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})) | |||
end | end | ||
end | end | ||
--Now just need the output quantity, xp, and casting time (which is always 2) | --Now just need the output quantity, xp, and casting time (which is always 2) | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Quantity\r\n|'..spell.convertToQty) | |||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base XP\r\n|'..spell.magicXP) | |||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Cast Time\r\n|2s') | |||
table.insert(resultPart, '\r\n|}') | |||
return | return table.concat(resultPart) | ||
end | end | ||
function p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq) | function p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq) | ||
if qty == nil then qty = 1 end | if qty == nil then qty = 1 end | ||
local | local resultPart = {} | ||
table.insert(resultPart, '{|class="wikitable"') | |||
if req ~= nil then | if req ~= nil then | ||
table.insert(resultPart, '\r\n!colspan="2"|Item Creation') | |||
else | else | ||
table.insert(resultPart, '\r\n!colspan="2"|Item Production') | |||
end | end | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align: right;"|Requirements') | |||
table.insert(resultPart, '\r\n|'..Icons._SkillReq(skill, lvl)) | |||
if specialReq ~= nil then | if specialReq ~= nil then table.insert(resultPart, '<br/>'..specialReq) end | ||
if req ~= nil then | if req ~= nil then | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align: right;"|Materials\r\n|') | |||
if type(req) == 'table' then | if type(req) == 'table' then | ||
for i, mat in pairs(req) do | for i, mat in pairs(req) do | ||
if i > 1 then | if i > 1 then table.insert(resultPart, '<br/>') end | ||
local matItem = Items.getItemByID(mat.id) | local matItem = Items.getItemByID(mat.id) | ||
if matItem == nil then | if matItem == nil then | ||
table.insert(resultPart, mat.qty..'x ?????') | |||
else | else | ||
table.insert(resultPart, Icons.Icon({matItem.name, type='item', qty=mat.qty})) | |||
end | end | ||
end | end | ||
else | else | ||
table.insert(resultPart, req) | |||
end | end | ||
end | end | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Quantity') | |||
table.insert(resultPart, '\r\n|'..qty) | |||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Experience') | |||
table.insert(resultPart, '\r\n|'..Shared.formatnum(xp)..' XP') | |||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Creation Time') | |||
table.insert(resultPart, '\r\n|'..Shared.formatnum(Shared.round(time, 2, 0))..'s') | |||
if maxTime ~= nil then | if maxTime ~= nil then table.insert(resultPart, ' - '..Shared.formatnum(Shared.round(maxTime, 2, 0))..'s') end | ||
table.insert(resultPart, '\r\n|}') | |||
return | return table.concat(resultPart) | ||
end | end | ||
Line 302: | Line 302: | ||
return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]" | return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]" | ||
end | end | ||
return p._getCreationTable(item) | return p._getCreationTable(item) | ||
end | end | ||
function p._getItemSources(item, asList, addCategories) | function p._getItemSources(item, asList, addCategories) | ||
local lineArray = {} | local lineArray = {} | ||
local categoryArray = {} | local categoryArray = {} | ||
Line 346: | Line 345: | ||
--If this is a boss then we actually are completing dungeons for this and need to figure out which one | --If this is a boss then we actually are completing dungeons for this and need to figure out which one | ||
for j, dung in pairs(areaList) do | for j, dung in pairs(areaList) do | ||
if string.len(dungeonStr) > 0 then | if string.len(dungeonStr) > 0 then | ||
dungeonStr = dungeonStr..',' | dungeonStr = dungeonStr..',' | ||
else | else | ||
Line 483: | Line 482: | ||
--MineCheck: | --MineCheck: | ||
if item. | if item.masteryID ~= nil and item.masteryID[1] == 4 then | ||
table.insert(lineArray, Icons._SkillReq("Mining", SkillData.Mining.Rocks[item.masteryID[2] + 1].level)) | table.insert(lineArray, Icons._SkillReq("Mining", SkillData.Mining.Rocks[item.masteryID[2] + 1].level)) | ||
end | end | ||
Line 495: | Line 494: | ||
--HerbCheck: | --HerbCheck: | ||
if item. | if item.masteryID ~= nil and item.masteryID[1] == 19 then | ||
local potionData = SkillData.Herblore.ItemData[item. | local potionData = SkillData.Herblore.ItemData[item.masteryID[2] + 1].herbloreLevel | ||
table.insert(lineArray, Icons._SkillReq("Herblore", potionData)) | table.insert(lineArray, Icons._SkillReq("Herblore", potionData)) | ||
end | end | ||
Line 563: | Line 562: | ||
--Tokens are from the appropriate skill | --Tokens are from the appropriate skill | ||
if item.isToken | if item.isToken and item.skill ~= nil then | ||
table.insert(lineArray, Icons._SkillReq(Constants.getSkillName(item.skill), 1)) | |||
end | end | ||
Line 582: | Line 577: | ||
end | end | ||
local | local resultPart = {} | ||
if asList then | if asList then | ||
table.insert(resultPart, '* '..table.concat(lineArray, "\r\n* ")) | |||
else | else | ||
table.insert(resultPart, '<div style="max-width:180px;text-align:right">' .. table.concat(lineArray, "<br/>") .. '</div>') | |||
end | end | ||
if addCategories then | if addCategories then table.insert(resultPart, table.concat(categoryArray, '')) end | ||
return | return table.concat(resultPart) | ||
end | end | ||
Line 598: | Line 592: | ||
local asList = false | local asList = false | ||
local addCategories = false | local addCategories = false | ||
if frame.args ~= nil then | if frame.args ~= nil then | ||
asList = frame.args.asList ~= nil and frame.args.asList ~= '' and frame.args.asList ~= 'false' | asList = frame.args.asList ~= nil and frame.args.asList ~= '' and frame.args.asList ~= 'false' | ||
addCategories = frame.args.addCategories ~= nil and frame.args.addCategories ~= '' and frame.args.addCategories ~= 'false' | addCategories = frame.args.addCategories ~= nil and frame.args.addCategories ~= '' and frame.args.addCategories ~= 'false' | ||
Line 610: | Line 604: | ||
function p._getItemLootSourceTable(item) | function p._getItemLootSourceTable(item) | ||
local | local resultPart = {} | ||
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') | |||
table.insert(resultPart, '\r\n|- class="headerRow-0"') | |||
table.insert(resultPart, '\r\n!Source!!Source Type!!Quantity!!colspan="2"|Chance') | |||
--Set up function for adding rows | --Set up function for adding rows | ||
local buildRow = function(source, type, minqty, qty, weight, totalWeight) | local buildRow = function(source, type, minqty, qty, weight, totalWeight) | ||
if minqty == nil then minqty = 1 end | if minqty == nil then minqty = 1 end | ||
local | local rowPart = {} | ||
table.insert(rowPart, '\r\n|-') | |||
table.insert(rowPart, '\r\n|style="text-align: left;"|'..source) | |||
table.insert(rowPart, '\r\n|style="text-align: left;"|'..type) | |||
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..minqty) | |||
if qty ~= minqty then | if qty ~= minqty then table.insert(rowPart, ' - '..qty) end | ||
local chance = Shared.round(weight / totalWeight * 100, 2, 2) | local chance = Shared.round(weight / totalWeight * 100, 2, 2) | ||
if weight >= totalWeight then | if weight >= totalWeight then | ||
-- Fraction would be 1/1, so only show the percentage | -- Fraction would be 1/1, so only show the percentage | ||
chance = 100 | chance = 100 | ||
table.insert(rowPart, '\r\n|colspan="2" ') | |||
else | else | ||
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="' .. chance .. '"| ' .. Shared.fraction(weight, totalWeight) .. '\r\n|') | |||
end | end | ||
table.insert(rowPart, 'style="text-align: right;" data-sort-value="'.. chance .. '"|'..chance..'%') | |||
return | return table.concat(rowPart) | ||
end | end | ||
local dropRows = {} | local dropRows = {} | ||
Line 769: | Line 765: | ||
if Shared.tableCount(dropRows) == 0 then return '' end | if Shared.tableCount(dropRows) == 0 then return '' end | ||
table.sort(dropRows, function(a, b) | table.sort(dropRows, function(a, b) | ||
if a.weight / a.totalWeight == b.weight / b.totalWeight then | if a.weight / a.totalWeight == b.weight / b.totalWeight then | ||
return a.minqty + a.qty > b.minqty + b.qty | return a.minqty + a.qty > b.minqty + b.qty | ||
Line 777: | Line 773: | ||
end) | end) | ||
for i, data in pairs(dropRows) do | for i, data in pairs(dropRows) do | ||
table.insert(resultPart, buildRow(data.source, data.type, data.minqty, data.qty, data.weight, data.totalWeight)) | |||
end | end | ||
table.insert(resultPart, '\r\n|}') | |||
return | return table.concat(resultPart) | ||
end | end | ||
Line 795: | Line 791: | ||
function p._getItemUpgradeTable(item) | function p._getItemUpgradeTable(item) | ||
local | local resultPart = {} | ||
if item.itemsRequired ~= nil then | if item.itemsRequired ~= nil then | ||
--First, get details on all the required materials | --First, get details on all the required materials | ||
Line 811: | Line 807: | ||
table.insert(materials, Icons.GP(item.trimmedGPCost)) | table.insert(materials, Icons.GP(item.trimmedGPCost)) | ||
end | end | ||
table.insert(resultPart, '{| class="wikitable"\r\n|-\r\n!colspan="2"|[[Upgrading Items|Item Upgrade]]') | |||
--[[result = result..'\r\n|-\r\n!style="text-align:right;"|Upgrades From\r\n|' | --[[result = result..'\r\n|-\r\n!style="text-align:right;"|Upgrades From\r\n|' | ||
result = result..table.concat(upgradeFrom, '<br/>')--]] | result = result..table.concat(upgradeFrom, '<br/>')--]] | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Materials\r\n|') | |||
table.insert(resultPart, table.concat(materials, '<br/>')) | |||
table.insert(resultPart, '\r\n|}') | |||
end | end | ||
return | return table.concat(resultPart) | ||
end | end | ||
Line 844: | Line 840: | ||
end | end | ||
end | end | ||
--Set up the header | |||
local superheatTable = '{|class="wikitable"\r\n!colspan="2"|Spell' | local superheatTable = {} | ||
superheatTable | table.insert(superheatTable, '{|class="wikitable"\r\n!colspan="2"|Spell') | ||
superheatTable | table.insert(superheatTable, '!!'..Icons.Icon({'Smithing', type='skill', notext='true'})..' Level') | ||
superheatTable | table.insert(superheatTable, '!!'..Icons.Icon({'Magic', type='skill', notext='true'})..' Level') | ||
superheatTable | table.insert(superheatTable, '!!'..Icons.Icon({'Magic', type='skill', notext='true'})..' XP') | ||
superheatTable | table.insert(superheatTable, '!!'..Icons.Icon({item.name, type='item', notext='true'})..' Bars') | ||
table.insert(superheatTable, '!!Ore!!Runes') | |||
--Loop through all the variants | --Loop through all the variants | ||
local spellNames = {'Superheat I', 'Superheat II', 'Superheat III', 'Superheat IV'} | local spellNames = {'Superheat I', 'Superheat II', 'Superheat III', 'Superheat IV'} | ||
for i, sName in pairs(spellNames) do | for i, sName in pairs(spellNames) do | ||
local spell = Magic.getSpell(sName, 'AltMagic') | local spell = Magic.getSpell(sName, 'AltMagic') | ||
local | local rowPart = {} | ||
table.insert(rowPart, '\r\n|-\r\n|'..Icons.Icon({spell.name, type='spell', notext=true, size=50})) | |||
table.insert(rowPart, '||[['..spell.name..']]||'..item.smithingLevel) | |||
table.insert(rowPart, '||'..spell.magicLevelRequired..'||'..spell.magicXP..'||'..spell.convertToQty) | |||
if spell.ignoreCoal ~= nil and not spell.ignoreCoal then | table.insert(rowPart, '||'..oreString) | ||
if spell.ignoreCoal ~= nil and not spell.ignoreCoal then table.insert(rowPart, coalString) end | |||
table.insert(rowPart, '||style="text-align:center"|') | |||
for i, req in pairs(spell.runesRequired) do | for i, req in pairs(spell.runesRequired) do | ||
local rune = Items.getItemByID(req.id) | local rune = Items.getItemByID(req.id) | ||
if i > 1 then | if i > 1 then table.insert(rowPart, ', ') end | ||
table.insert(rowPart, Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})) | |||
end | end | ||
table.insert(rowPart, "<br/>'''OR'''<br/>") | |||
for i, req in pairs(spell.runesRequiredAlt) do | for i, req in pairs(spell.runesRequiredAlt) do | ||
local rune = Items.getItemByID(req.id) | local rune = Items.getItemByID(req.id) | ||
if i > 1 then | if i > 1 then table.insert(rowPart, ', ') end | ||
table.insert(rowPart, Icons.Icon({rune.name, type='item', notext=true, qty=req.qty})) | |||
end | end | ||
superheatTable | table.insert(superheatTable, table.concat(rowPart)) | ||
end | end | ||
--Add the table end and add the table to the result string | --Add the table end and add the table to the result string | ||
superheatTable | table.insert(superheatTable, '\r\n|}') | ||
return superheatTable | return table.concat(superheatTable) | ||
end | end | ||
Line 890: | Line 888: | ||
function p._getItemSourceTables(item) | function p._getItemSourceTables(item) | ||
local | local resultPart = {} | ||
local shopTable = Shop._getItemShopTable(item) | local shopTable = Shop._getItemShopTable(item) | ||
if string.len(shopTable) > 0 then | if string.len(shopTable) > 0 then | ||
table.insert(resultPart, '===Shop===\r\n'..shopTable) | |||
end | end | ||
local creationTable = p._getCreationTable(item) | local creationTable = p._getCreationTable(item) | ||
if string.len(creationTable) > 0 then | if string.len(creationTable) > 0 then | ||
if | if #resultPart > 0 then table.insert(resultPart, '\r\n') end | ||
table.insert(resultPart, '===Creation===\r\n'..creationTable) | |||
end | end | ||
local upgradeTable = p._getItemUpgradeTable(item) | local upgradeTable = p._getItemUpgradeTable(item) | ||
if string.len(upgradeTable) > 0 then | if string.len(upgradeTable) > 0 then | ||
if | if #resultPart > 0 then table.insert(resultPart, '\r\n') end | ||
if string.len(creationTable) == 0 then | if string.len(creationTable) == 0 then table.insert(resultPart, '===Creation===\r\n') end | ||
table.insert(resultPart, upgradeTable) | |||
end | end | ||
if item.type == 'Bar' then | if item.type == 'Bar' then | ||
table.insert(resultPart, '\r\n==='..Icons.Icon({'Alt Magic', type='skill'})..'===\r\n'..p._getItemSuperheatTable(item)) | |||
end | end | ||
local lootTable = p._getItemLootSourceTable(item) | local lootTable = p._getItemLootSourceTable(item) | ||
if string.len(lootTable) > 0 then | if string.len(lootTable) > 0 then | ||
if | if #resultPart > 0 then table.insert(resultPart, '\r\n') end | ||
table.insert(resultPart, '===Loot===\r\n'..lootTable) | |||
end | end | ||
return | return table.concat(resultPart) | ||
end | end | ||
Line 932: | Line 930: | ||
function p.getCombatPassiveSlotItems(frame) | function p.getCombatPassiveSlotItems(frame) | ||
local | local resultPart = {} | ||
table.insert(resultPart, '{| class="wikitable"\r\n') | |||
table.insert(resultPart, '|-\r\n') | |||
table.insert(resultPart, '!colspan="2"|Item\r\n! Passive\r\n') | |||
local itemArray = Items.getItems(function(item) return item. | local itemArray = Items.getItems(function(item) return item.validSlots ~= nil and Shared.contains(item.validSlots, 'Passive') end) | ||
table.sort(itemArray, function(a, b) return a.id < b.id end) | table.sort(itemArray, function(a, b) return a.id < b.id end) | ||
for i, item in Shared.skpairs(itemArray) do | for i, item in Shared.skpairs(itemArray) do | ||
table.insert(resultPart, '|-\r\n') | |||
table.insert(resultPart, '! '..Icons.Icon({item.name, type='item', notext='true'})..'\r\n! [['..item.name..']]\r\n') | |||
table.insert(resultPart, '| '..item.description..'\r\n') | |||
end | end | ||
return | table.insert(resultPart, '|}') | ||
return table.concat(resultPart) | |||
end | end | ||
return p | return p |