12,714
edits
(Update for v1.0.3) |
(Alt Magic -> Alt. Magic for consistency) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
local Shop = require('Module:Shop') | local Shop = require('Module:Shop') | ||
local Monsters = require('Module:Monsters') | local Monsters = require('Module:Monsters') | ||
local | local Skills = require('Module:Skills') | ||
local SkillEnum = mw.loadData('Module:Constants/data').skill | local SkillEnum = mw.loadData('Module:Constants/data').skill | ||
Line 110: | Line 110: | ||
table.insert(reqSubPart, itemCost.qty .. 'x ?????') | table.insert(reqSubPart, itemCost.qty .. 'x ?????') | ||
else | else | ||
table.insert(reqSubPart, Icons.Icon({reqItem.name, type='item', qty= | table.insert(reqSubPart, Icons.Icon({reqItem.name, type='item', qty=itemCost.qty})) | ||
end | end | ||
end | |||
if recipe.gpCost ~= nil and recipe.gpCost > 0 then | |||
table.insert(reqSubPart, Icons.GP(recipe.gpCost)) | |||
end | |||
if recipe.scCost ~= nil and recipe.scCost > 0 then | |||
table.insert(reqSubPart, Icons.GP(recipe.scCost)) | |||
end | end | ||
table.insert(reqPart, table.concat(reqSubPart, ', ')) | table.insert(reqPart, table.concat(reqSubPart, ', ')) | ||
Line 122: | Line 128: | ||
elseif type(recipe.itemCosts) == 'table' and Shared.tableCount(recipe.itemCosts) > 0 then | elseif type(recipe.itemCosts) == 'table' and Shared.tableCount(recipe.itemCosts) > 0 then | ||
req = recipe.itemCosts | req = recipe.itemCosts | ||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, baseQty, time, maxTime, specialReq)) | table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, baseQty, time, maxTime, specialReq, recipe.gpCost, recipe.scCost)) | ||
end | end | ||
end | end | ||
Line 154: | Line 160: | ||
local nonShard = Items.getItemByID(nonShardID) | local nonShard = Items.getItemByID(nonShardID) | ||
if nonShard ~= nil then | if nonShard ~= nil then | ||
local itemValue = math.max( | local itemValue = math.max(nonShard.sellsFor, 20) | ||
local nonShardQty = math.max(1, math.floor(recipeGPCost / itemValue)) | local nonShardQty = math.max(1, math.floor(recipeGPCost / itemValue)) | ||
table.insert(OtherCostArray, Icons.Icon({nonShard.name, type='item', notext=true, qty=nonShardQty})) | table.insert(OtherCostArray, Icons.Icon({nonShard.name, type='item', notext=true, qty=nonShardQty})) | ||
Line 239: | Line 245: | ||
local spell = Magic.getSpell(spellName, 'AltMagic') | local spell = Magic.getSpell(spellName, 'AltMagic') | ||
if spell == nil then | if spell == nil then | ||
return 'ERROR: Could not find Alt Magic spell "' .. spellName .. '"[[Category:Pages with script errors]]' | return 'ERROR: Could not find Alt. Magic spell "' .. spellName .. '"[[Category:Pages with script errors]]' | ||
else | else | ||
return p._buildAltMagicTable(spell) | return p._buildAltMagicTable(spell) | ||
Line 252: | Line 258: | ||
table.insert(resultPart, '\r\n|'..Icons._SkillReq('Magic', spell.level)) | table.insert(resultPart, '\r\n|'..Icons._SkillReq('Magic', spell.level)) | ||
-- The produces property of Alt | -- The produces property of Alt. Magic spells is as follows: | ||
-- -3 = A random gem, using the same weights as Mining | -- -3 = A random gem, using the same weights as Mining | ||
-- -2 = A bar of the type being created (Superheat) | -- -2 = A bar of the type being created (Superheat) | ||
Line 260: | Line 266: | ||
-- The amount produced is determined by the productionRatio property | -- The amount produced is determined by the productionRatio property | ||
-- The consumes property of Alt Magic spells is as follows: | -- The consumes property of Alt. Magic spells is as follows: | ||
-- 0 = Any item | -- 0 = Any item | ||
-- 1 = Junk item | -- 1 = Junk item | ||
Line 295: | Line 301: | ||
end | end | ||
function p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq, gpCost) | function p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq, gpCost, scCost) | ||
if qty == nil then qty = 1 end | if qty == nil then qty = 1 end | ||
local resultPart = {} | local resultPart = {} | ||
Line 323: | Line 329: | ||
table.insert(resultPart, '<br/>') | table.insert(resultPart, '<br/>') | ||
table.insert(resultPart, Icons.GP(gpCost)) | table.insert(resultPart, Icons.GP(gpCost)) | ||
end | |||
if scCost ~= nil and scCost > 0 then | |||
table.insert(resultPart, '<br/>') | |||
table.insert(resultPart, Icons.SC(scCost)) | |||
end | end | ||
else | else | ||
Line 440: | Line 450: | ||
--Next: Can we take it from somebody else -without- killing them? | --Next: Can we take it from somebody else -without- killing them? | ||
local thiefItems = | local thiefItems = Skills.getThievingSourcesForItem(item.id) | ||
if type(thiefItems) == 'table' then | if type(thiefItems) == 'table' then | ||
local thiefPart = {} | local thiefPart = {} | ||
Line 471: | Line 481: | ||
local keyData = { | local keyData = { | ||
[SkillEnum.Fishing] = { ["recipe"] = 'Fish' }, | [SkillEnum.Fishing] = { ["recipe"] = 'Fish' }, | ||
[SkillEnum.Mining] = { ["recipe"] = 'Rocks', ["level"] = 'levelRequired' }, | [SkillEnum.Mining] = { ["recipe"] = 'Rocks', ["level"] = 'levelRequired', ["item"] = 'oreID' }, | ||
[SkillEnum.Smithing] = {}, | [SkillEnum.Smithing] = {}, | ||
[SkillEnum.Fletching] = {}, | [SkillEnum.Fletching] = {}, | ||
[SkillEnum.Crafting] = {}, | [SkillEnum.Crafting] = {}, | ||
[SkillEnum.Runecrafting] = {}, | [SkillEnum.Runecrafting] = {}, | ||
[SkillEnum.Herblore] = { ["recipe"] = 'Potions' }, | [SkillEnum.Herblore] = { ["recipe"] = 'Potions', ["item"] = 'potionIDs', ["isItemList"] = true }, | ||
[SkillEnum.Summoning] = { ["recipe"] = 'Marks' } | [SkillEnum.Summoning] = { ["recipe"] = 'Marks' } | ||
} | } | ||
Line 486: | Line 496: | ||
if keys.level == nil then | if keys.level == nil then | ||
keys.level = 'level' | keys.level = 'level' | ||
end | |||
if keys.item == nil then | |||
keys.item = 'itemID' | |||
end | |||
if keys.isItemList == nil then | |||
keys.isItemList = false | |||
end | end | ||
local recipe = SkillData[skill][keys.recipe][masteryID + 1] | local recipe = SkillData[skill][keys.recipe][masteryID + 1] | ||
if recipe ~= nil and recipe. | if recipe ~= nil and ( | ||
(not keys.isItemList and recipe[keys.item] == item.id) or | |||
(keys.isItemList and Shared.contains(recipe[keys.item], item.id))) then | |||
local levelReq = recipe[keys.level] | local levelReq = recipe[keys.level] | ||
if levelReq ~= nil then | if levelReq ~= nil then | ||
Line 764: | Line 782: | ||
--Finally, let's try just stealing it | --Finally, let's try just stealing it | ||
local thiefType = Icons.Icon({"Thieving", type='skill'}) | local thiefType = Icons.Icon({"Thieving", type='skill'}) | ||
local thiefItems = | local thiefItems = Skills.getThievingSourcesForItem(item.id) | ||
for i, thiefRow in ipairs(thiefItems) do | for i, thiefRow in ipairs(thiefItems) do | ||
local sourceTxt = '' | local sourceTxt = '' | ||
Line 858: | Line 876: | ||
table.insert(materials, Icons.Icon({mat.name, type='item', qty=row[2]})) | table.insert(materials, Icons.Icon({mat.name, type='item', qty=row[2]})) | ||
end | end | ||
if item.trimmedGPCost | if type(item.trimmedGPCost) == 'number' and item.trimmedGPCost > 0 then | ||
table.insert(materials, Icons.GP(item.trimmedGPCost)) | table.insert(materials, Icons.GP(item.trimmedGPCost)) | ||
end | end | ||
Line 969: | Line 987: | ||
local recipe = SkillData.Smithing.Recipes[item.masteryID[2] + 1] | local recipe = SkillData.Smithing.Recipes[item.masteryID[2] + 1] | ||
if recipe ~= nil and recipe.category == 0 then | if recipe ~= nil and recipe.category == 0 then | ||
table.insert(resultPart, '\r\n==='..Icons.Icon({'Alt Magic', type='skill'})..'===\r\n'..p._getItemSuperheatTable(item)) | table.insert(resultPart, '\r\n==='..Icons.Icon({'Alt. Magic', type='skill'})..'===\r\n'..p._getItemSuperheatTable(item)) | ||
end | end | ||
end | end | ||
Line 1,090: | Line 1,108: | ||
'Mysterious Stone', | 'Mysterious Stone', | ||
'Mastery Token (Cooking)', | 'Mastery Token (Cooking)', | ||
'Gem Gloves' | 'Gem Gloves', | ||
"Thief's Moneysack" | |||
} | } | ||
local checkFuncs = { | local checkFuncs = { |