4,951
edits
Falterfire (talk | contribs) (another attempt to fix formatting) |
Falterfire (talk | contribs) (Improvements to the getItemSources code to account for more things. Probably not everything quite yet, but getting there) |
||
Line 201: | Line 201: | ||
function p._getItemSources(item) | function p._getItemSources(item) | ||
local result = | local result = nil | ||
local lineArray = {} | |||
--Alright, time to go through all the ways you can get an item... | --Alright, time to go through all the ways you can get an item... | ||
--First up: Can we kill somebody and take theirs? | --First up: Can we kill somebody and take theirs? | ||
local | local killStr = '' | ||
for i, monster in pairs(MonsterData.Monsters) do | for i, monster in pairs(MonsterData.Monsters) do | ||
if monster.lootTable ~= nil then | if monster.lootTable ~= nil then | ||
for j, loot in pairs(monster.lootTable) do | for j, loot in pairs(monster.lootTable) do | ||
if loot[1] == item.id then | if loot[1] == item.id then | ||
if | if string.len(killStr) > 0 then | ||
killStr = killStr..','..Icons.Icon({monster.name, type="monster", notext="true"}) | |||
else | else | ||
killStr = killStr..'Killing: '..Icons.Icon({monster.name, type="monster", notext="true"}) | |||
end | end | ||
end | end | ||
Line 219: | Line 220: | ||
end | end | ||
end | end | ||
if string.len(killStr) > 0 then table.insert(lineArray, killStr) end | |||
--Next: Can we find it in a box? | --Next: Can we find it in a box? | ||
local | --While we're here, check for upgrades, cooking, and growing | ||
for i, | local lootStr = '' | ||
if | local upgradeStr = '' | ||
for j, loot in pairs( | local cookStr = '' | ||
local burnStr = '' | |||
local growStr = '' | |||
for i, item2 in pairs(ItemData) do | |||
if item2.dropTable ~= nil then | |||
for j, loot in pairs(item2.dropTable) do | |||
if loot[1] == item.id then | if loot[1] == item.id then | ||
if | if string.len(lootStr) > 0 then | ||
lootStr = lootStr..','..Icons.Icon({item2.name, type="item", notext="true"}) | |||
else | else | ||
lootStr = lootStr..'Opening: '..Icons.Icon({item2.name, type="item", notext="true"}) | |||
end | end | ||
end | end | ||
end | end | ||
end | |||
if item2.trimmedItemID == item.id then | |||
if string.len(upgradeStr) > 0 then | |||
upgradeStr = upgradeStr..','..Icons.Icon({item2.name, type="item", notext="true"}) | |||
else | |||
upgradeStr = upgradeStr..'Upgrading: '..Icons.Icon({item2.name, type="item", notext="true"}) | |||
end | |||
end | |||
if item2.cookedItemID == item.id then | |||
if string.len(cookStr) > 0 then | |||
cookStr = cookStr..','..Icons.Icon({item2.name, type="item", notext="true"}) | |||
else | |||
cookStr = cookStr..'Cooking: '..Icons.Icon({item2.name, type="item", notext="true"}) | |||
end | |||
end | |||
if item2.burntItemID == item.id then | |||
if string.len(burnStr) > 0 then | |||
burnStr = burnStr..','..Icons.Icon({item2.name, type="item", notext="true"}) | |||
else | |||
burnStr = burnStr..'Burning: '..Icons.Icon({item2.name, type="item", notext="true"}) | |||
end | |||
end | |||
if item2.grownItemID == item.id then | |||
if string.len(growStr) > 0 then | |||
growStr = growStr..','..Icons.Icon({item2.name, type="item", notext="true"}) | |||
else | |||
growStr = growStr..'Growing: '..Icons.Icon({item2.name, type="item", notext="true"}) | |||
end | |||
end | end | ||
end | end | ||
if string.len(lootStr) > 0 then table.insert(lineArray, lootStr) end | |||
if string.len(upgradeStr) > 0 then table.insert(lineArray, upgradeStr) end | |||
if string.len(cookStr) > 0 then table.insert(lineArray, cookStr) end | |||
if string.len(burnStr) > 0 then table.insert(lineArray, burnStr) end | |||
if string.len(growStr) > 0 then table.insert(lineArray, growStr) end | |||
--Next: Can we take it from somebody else -without- killing them? | --Next: Can we take it from somebody else -without- killing them? | ||
local thiefStr = '' | |||
for i, npc in pairs(SkillData.Thieving) do | for i, npc in pairs(SkillData.Thieving) do | ||
if npc.lootTable ~= nil then | if npc.lootTable ~= nil then | ||
for j, loot in pairs(npc.lootTable) do | for j, loot in pairs(npc.lootTable) do | ||
if loot[1] == item.id then | if loot[1] == item.id then | ||
if string.len( | if string.len(thiefStr) > 0 then | ||
thiefStr = thiefStr..','..Icons.Icon({npc.name, type="item", notext="true"}) | |||
else | |||
thiefStr = thiefStr..'Pickpocketing: '..Icons.Icon({npc.name, type="item", notext="true"}) | |||
end | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
if string.len(thiefStr) > 0 then table.insert(lineArray, thiefStr) end | |||
--If all else fails, I guess we should check if we can make it ourselves | --If all else fails, I guess we should check if we can make it ourselves | ||
--SmithCheck: | --SmithCheck: | ||
if item.smithingLevel ~= nil then | if item.smithingLevel ~= nil then | ||
table.insert(lineArray, Icons._SkillReq("Smithing", item.smithingLevel)) | |||
end | end | ||
--CraftCheck: | --CraftCheck: | ||
if item.craftingLevel ~= nil then | if item.craftingLevel ~= nil then | ||
table.insert(lineArray, Icons._SkillReq("Crafting", item.craftingLevel)) | |||
end | end | ||
--FletchCheck: | --FletchCheck: | ||
if item.fletchingLevel ~= nil then | if item.fletchingLevel ~= nil then | ||
table.insert(lineArray, Icons._SkillReq("Fletching", item.fletchingLevel)) | |||
end | end | ||
--RunecraftCheck: | --RunecraftCheck: | ||
if item.runecraftingLevel ~= nil then | if item.runecraftingLevel ~= nil then | ||
table.insert(lineArray, Icons._SkillReq("Runecrafting", item.runecraftingLevel)) | |||
end | |||
--MineCheck: | |||
if item.miningLevel ~= nil then | |||
table.insert(lineArray, Icons._SkillReq("Mining", item.miningLevel)) | |||
end | end | ||
--FishCheck: | --FishCheck: | ||
if (item.category == "Fishing" and (item.type == "Junk" or item.type == "Special")) | if (item.category == "Fishing" and (item.type == "Junk" or item.type == "Special")) then | ||
table.insert(lineArray, Icons._SkillReq("Fishing", 1)) | |||
elseif item.fishingLevel ~= nil then | |||
elseif item. | table.insert(lineArray, Icons._SkillReq("Fishing", item.fishingLevel)) | ||
end | |||
--HerbCheck: | |||
if item.herbloreMasteryID ~= nil then | |||
local potionData = SkillData.Herblore.ItemData[item.herbloreMasteryID + 1].herbloreLevel | |||
table.insert(lineArray, Icons._SkillReq("Herblore", potionData)) | |||
end | end | ||
--Finally there are some weird exceptions: | --Finally there are some weird exceptions: | ||
-- | --Coal can be acquired via firemaking | ||
if item. | if item.name == "Coal Ore" then | ||
table.insert(lineArray, Icons._SkillReq("Firemaking", 1)) | |||
end | |||
--Gems can be acquired from both mining & fishing | |||
if item.type == 'Gem' then | |||
table.insert(lineArray, Icons._SkillReq("Fishing", 1)) | |||
table.insert(lineArray, Icons._SkillReq("Mining", 1)) | |||
end | |||
--Tokens are from the appropriate skill | |||
if item.isToken then | |||
for skill, id in pairs(Constants.skill) do | |||
if id == item.skill then | |||
table.insert(lineArray, Icons._SkillReq(skill, 1)) | |||
end | |||
end | |||
end | end | ||
-- | --Shop items (including special items like gloves that aren't otherwise listed) | ||
if Shared.contains(OtherShopItems, item.name) then | if item.slayerCost ~= nil or item.buysFor ~= nil or Shared.contains(OtherShopItems, item.name) then | ||
table.insert(lineArray, '[[Shop]]') | |||
end | end | ||
--Easter Eggs (manual list 'cause don't have a better way to do that) | --Easter Eggs (manual list 'cause don't have a better way to do that) | ||
if Shared.contains(EasterEggs, item.name) then | if Shared.contains(EasterEggs, item.name) then | ||
table.insert(lineArray, '[[Easter Eggs]]') | |||
end | end | ||
return | return table.concat(lineArray, "<br/>") | ||
end | end | ||