572
edits
No edit summary |
No edit summary |
||
Line 100: | Line 100: | ||
-- Returns the recipe for the item of a desired skill. | -- Returns the recipe for the item of a desired skill. | ||
function Data.Item.FindRecipes(itemid, skill) | function Data.Item.FindRecipes(itemid, skill) | ||
-- No skill? No recipes | |||
if skill == nil then | |||
return {} | |||
end | |||
-- the key name for each skill in the json file | -- the key name for each skill in the json file | ||
local skill_recipe_keys = { | local skill_recipe_keys = { | ||
Woodcutting = {recipes='trees', productID='productId'}, -- lowercase "d" | ['melvorD:Woodcutting'] = {recipes='trees', productID='productId'}, -- lowercase "d" | ||
Fishing = {recipes='fish', productID='productId'}, -- lowercase "d" | ['melvorD:Fishing'] = {recipes='fish', productID='productId'}, -- lowercase "d" | ||
Cooking = {recipes='recipes', productID='productID'}, | ['melvorD:Cooking'] = {recipes='recipes', productID='productID'}, | ||
Mining = {recipes='rockData', productID='productId'}, -- lowercase "d" | ['melvorD:Mining'] = {recipes='rockData', productID='productId'}, -- lowercase "d" | ||
Smithing = {recipes='recipes', productID='productID'}, | ['melvorD:Smithing'] = {recipes='recipes', productID='productID'}, | ||
Farming = {recipes='recipes', productID='productId'}, -- lowercase "d" | ['melvorD:Farming'] = {recipes='recipes', productID='productId'}, -- lowercase "d" | ||
Summoning = {recipes='recipes', productID='productID'}, | ['melvorD:Summoning'] = {recipes='recipes', productID='productID'}, | ||
Fletching = {recipes='recipes', productID='productID'}, | ['melvorD:Fletching'] = {recipes='recipes', productID='productID'}, | ||
Crafting = {recipes='recipes', productID='productID'}, | ['melvorD:Crafting'] = {recipes='recipes', productID='productID'}, | ||
Runecrafting = {recipes='recipes', productID='productID'}, | ['melvorD:Runecrafting'] = {recipes='recipes', productID='productID'}, | ||
Herblore = {recipes='recipes', productID='potionIDs'} -- Special case potions I-IV | ['melvorD:Herblore'] = {recipes='recipes', productID='potionIDs'} -- Special case potions I-IV | ||
--[[ Excluded skills: | --[[ Excluded skills: | ||
Attack, Strength, Defence, Magic, Ranged, Prayer, Slayer | Attack, Strength, Defence, Magic, Ranged, Prayer, Slayer | ||
Line 118: | Line 124: | ||
} | } | ||
local results = {} | local results = {} | ||
local SkillData = GameData.getSkillData(skill) | |||
local recipes = skill_recipe_keys[skill].recipes | |||
local productID = skill_recipe_keys[skill].productID | |||
if SkillData[recipes] ~= nil then | |||
for _, recipe in ipairs(SkillData[recipes]) do | |||
-- Special case for Herblore | |||
if skill == 'Herblore' then | |||
-- Iterate over the 4 potion tiers | |||
for _, potion in ipairs(recipe[productID]) do | |||
if itemid == potion.id then | |||
table.insert(results, Shared.clone(recipe)) | |||
end | end | ||
end | |||
-- Base case | |||
else | |||
if itemid == recipe[productID] then | |||
table.insert(results, Shared.clone(recipe)) | |||
end | end | ||
end | end | ||
end | end | ||
end | end | ||
return results | return results | ||
end | end | ||
Line 174: | Line 165: | ||
local resource_data = { | local resource_data = { | ||
['melvorF:GP'] = {_icon = {'Coins'}, _skill = nil}, | ['melvorF:GP'] = {_icon = {'Coins'}, _skill = nil}, | ||
['melvorF:Food'] = {_icon = {'Raw Beef', type='item'}, _skill = 'Cooking'}, | ['melvorF:Food'] = {_icon = {'Raw Beef', type='item'}, _skill = 'melvorD:Cooking'}, | ||
['melvorF:Wood'] = {_icon = {'Wood', type='resource'}, _skill = 'Woodcutting'}, | ['melvorF:Wood'] = {_icon = {'Wood', type='resource'}, _skill = 'melvorD:Woodcutting'}, | ||
['melvorF:Stone'] = {_icon = {'Stone', type='resource'}, _skill = 'Mining'}, | ['melvorF:Stone'] = {_icon = {'Stone', type='resource'}, _skill = 'melvorD:Mining'}, | ||
['melvorF:Ore'] = {_icon = {'Iron Ore', type='rock'}, _skill = 'Mining'}, | ['melvorF:Ore'] = {_icon = {'Iron Ore', type='rock'}, _skill = 'melvorD:Mining'}, | ||
['melvorF:Coal'] = {_icon = {'Coal', type='resource'}, _skill = 'Mining'}, | ['melvorF:Coal'] = {_icon = {'Coal', type='resource'}, _skill = 'melvorD:Mining'}, | ||
['melvorF:Bar'] = {_icon = {'Iron Bar', type='item'}, _skill = 'Mining'}, | ['melvorF:Bar'] = {_icon = {'Iron Bar', type='item'}, _skill = 'melvorD:Mining'}, | ||
['melvorF:Herbs'] = {_icon = {'Garum Herb', type='item'}, _skill = 'Farming'}, | ['melvorF:Herbs'] = {_icon = {'Garum Herb', type='item'}, _skill = 'melvorD:Farming'}, | ||
['melvorF:Rune_Essence'] = {_icon = {'Rune Essence', type='item'}, _skill = 'Mining'}, | ['melvorF:Rune_Essence'] = {_icon = {'Rune Essence', type='item'}, _skill = 'melvorD:Mining'}, | ||
['melvorF:Leather'] = {_icon = {'Leather', type='item'}, _skill = nil}, | ['melvorF:Leather'] = {_icon = {'Leather', type='item'}, _skill = nil}, | ||
['melvorF:Potions'] = {_icon = {'Potion', type='resource'}, _skill = 'Herblore'}, | ['melvorF:Potions'] = {_icon = {'Potion', type='resource'}, _skill = 'melvorD:Herblore'}, | ||
['melvorF:Planks'] = {_icon = {'Planks', type='resource'}, _skill = 'Woodcutting'}, | ['melvorF:Planks'] = {_icon = {'Planks', type='resource'}, _skill = 'melvorD:Woodcutting'}, | ||
['melvorF:Clothing'] = {_icon = {'Leather Body', type='item'}, _skill = 'Crafting'} | ['melvorF:Clothing'] = {_icon = {'Leather Body', type='item'}, _skill = 'melvorD:Crafting'} | ||
} | } | ||
for _, resource in ipairs(resources) do | for _, resource in ipairs(resources) do | ||
Line 334: | Line 325: | ||
-- Get the skill based on the item.id or else use the resource's default skill | -- Get the skill based on the item.id or else use the resource's default skill | ||
local skill_overrides = { | local skill_overrides = { | ||
['melvorD:Raw_Magic_Fish'] = 'Fishing', | ['melvorD:Raw_Magic_Fish'] = 'melvorD:Fishing', | ||
['melvorF:Apple'] = 'Farming', | ['melvorF:Apple'] = 'melvorD:Farming', | ||
} | } | ||
local skill = skill_overrides[item.id] or resource._skill | local skill = skill_overrides[item.id] or resource._skill | ||
Line 375: | Line 366: | ||
-- Value/Resource | -- Value/Resource | ||
table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. item.sellsFor/item.fromTownship .. '"|'..Icons.GP(Shared.round(item.sellsFor/item.fromTownship, 2, 2))) | table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. item.sellsFor/item.fromTownship .. '"|'..Icons.GP(Shared.round(item.sellsFor/item.fromTownship, 2, 2))) | ||
if resource.id =='Food' then | if resource.id =='melvorF:Food' then | ||
-- Heals | -- Heals | ||
table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. item.healsFor*10 .. '"|'..Icons.Icon({"Hitpoints", type="skill", notext=true})..' '..Shared.formatnum(item.healsFor*10)) | table.insert(ret_resource, '\r\n|style="text-align:center" data-sort-value="' .. item.healsFor*10 .. '"|'..Icons.Icon({"Hitpoints", type="skill", notext=true})..' '..Shared.formatnum(item.healsFor*10)) |
edits