Anonymous

Module:Items/SourceTables: Difference between revisions

From Melvor Idle
Add recipe categories to Sources/Creation table; Add Harvesting creation data
(Add depths and stronghold source for ItemBox)
(Add recipe categories to Sources/Creation table; Add Harvesting creation data)
Line 22: Line 22:
local skill = ''
local skill = ''
local specialReq = nil
local specialReq = nil
local category = nil
local time = 0
local time = 0
local maxTime = nil
local maxTime = nil
Line 39: Line 40:
['Fishing'] = { recipeKey = 'fish' },
['Fishing'] = { recipeKey = 'fish' },
['Mining'] = { recipeKey = 'rockData' },
['Mining'] = { recipeKey = 'rockData' },
['Farming'] = { recipeKey = 'recipes' }
['Farming'] = { recipeKey = 'recipes' },
['Harvesting'] = { recipeKey = 'veinData' }
},
},
['Artisan'] = {
['Artisan'] = {
Line 57: Line 59:
local skillData = SkillData[localSkillID]
local skillData = SkillData[localSkillID]
local skill = skillData.name
local skill = skillData.name
local lvl, isAbyssal, xp, qty, req, time, maxTime = 0, false, 0, 0, nil, 0, nil
local lvl, isAbyssal, xp, qty, req, category, time, maxTime = 0, false, 0, 0, nil, nil, 0, nil
for i, recipe in ipairs(skillData[dataProp.recipeKey]) do
for i, recipe in ipairs(skillData[dataProp.recipeKey]) do
if recipe.productId == itemID then
local hasProduct = recipe.productId == itemID
if hasProduct ~= true and type(recipe.products) == 'table' then
for i, product in ipairs(recipe.products) do
if product.itemID == itemID then
hasProduct = true
if recipe.products[i].minIntensityPercent ~= nil then
specialReq = recipe.products[i].minIntensityPercent .. '% Intensity'
end
break
end
end
end
if hasProduct then
lvl, isAbyssal = Skills.getRecipeLevelRealm(localSkillID, recipe)
lvl, isAbyssal = Skills.getRecipeLevelRealm(localSkillID, recipe)
xp = recipe.baseAbyssalExperience or recipe.baseExperience
xp = recipe.baseAbyssalExperience or recipe.baseExperience
Line 65: Line 79:
if localSkillID == 'Farming' then
if localSkillID == 'Farming' then
req = { recipe.seedCost }
req = { recipe.seedCost }
local category = GameData.getEntityByID(skillData.categories, recipe.categoryID)
local catData = GameData.getEntityByID(skillData.categories, recipe.categoryID)
qty = 5 * category.harvestMultiplier
category = catData.name
qty = 5 * catData.harvestMultiplier
end
end
-- Action time
-- Action time
Line 83: Line 98:
specialReq = Icons.Icon({'Mastery', notext=true}) .. Num.formatnum(recipe.totalMasteryRequired) .. ' total [[' .. skill .. ']] [[Mastery]]'
specialReq = Icons.Icon({'Mastery', notext=true}) .. Num.formatnum(recipe.totalMasteryRequired) .. ' total [[' .. skill .. ']] [[Mastery]]'
end
end
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, time, maxTime, specialReq))
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, category, time, maxTime, specialReq))
-- Assumes item has a single source per skill
-- Assumes item has a single source per skill
break
break
Line 95: Line 110:
local skillData = SkillData[localSkillID]
local skillData = SkillData[localSkillID]
local skill = skillData.name
local skill = skillData.name
local lvl, isAbyssal, xp, qty, req, time, maxTime = 0, false, 0, 0, nil, 0, nil
local lvl, isAbyssal, xp, qty, category, req, time, maxTime = 0, false, 0, 0, nil, nil, 0, nil
for i, recipe in ipairs(skillData.recipes) do
for i, recipe in ipairs(skillData.recipes) do
if recipe.productID == itemID or
if recipe.productID == itemID or
Line 103: Line 118:
xp = recipe.baseAbyssalExperience or recipe.baseExperience
xp = recipe.baseAbyssalExperience or recipe.baseExperience
qty = recipe.baseQuantity or 1
qty = recipe.baseQuantity or 1
-- Recipe Category
if recipe.categoryID ~= nil then
local catData = GameData.getEntityByID(SkillData[localSkillID].categories, recipe.categoryID)
category = catData.modifierName or catData.name or nil
end
-- Action time
-- Action time
if recipe.baseMinInterval ~= nil then
if recipe.baseMinInterval ~= nil then
Line 155: Line 175:
end
end
specialReq = 'At least 1 ' .. Icons.Icon({'Summoning%23Summoning Marks', item.name, img=item.name, type='mark'}) .. ' mark discovered'
specialReq = 'At least 1 ' .. Icons.Icon({'Summoning%23Summoning Marks', item.name, img=item.name, type='mark'}) .. ' mark discovered'
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, time, nil, specialReq))
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, category, time, nil, specialReq))
-- Some items (such as Arrow shafts) have multiple recipes
-- Some items (such as Arrow shafts) have multiple recipes
elseif type(recipe.alternativeCosts) == 'table' then
elseif type(recipe.alternativeCosts) == 'table' then
Line 177: Line 197:
req = table.concat(reqPart, sep)
req = table.concat(reqPart, sep)
local qtyText = table.concat(qtyPart, sep)
local qtyText = table.concat(qtyPart, sep)
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qtyText, time, maxTime, specialReq))
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qtyText, category, time, maxTime, specialReq))
-- Finally, normal recipes with a single set of item costs
-- Finally, normal recipes with a single set of item costs
elseif type(recipe.itemCosts) == 'table' and not Shared.tableIsEmpty(recipe.itemCosts) then
elseif type(recipe.itemCosts) == 'table' and not Shared.tableIsEmpty(recipe.itemCosts) then
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, recipe.itemCosts, qty, time, maxTime, specialReq, recipe.currencyCosts))
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, recipe.itemCosts, qty, category, time, maxTime, specialReq, recipe.currencyCosts))
end
end
end
end
Line 237: Line 257:
end
end


function p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, time, maxTime, specialReq, currencyCost)
function p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, category, time, maxTime, specialReq, currencyCost)
if qty == nil then qty = 1 end
if qty == nil then qty = 1 end
local resultPart = {}
local resultPart = {}
Line 265: Line 285:
table.insert(resultPart, req)
table.insert(resultPart, req)
end
end
end
if category ~= nil then
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Recipe Category')
table.insert(resultPart, '\r\n|'..category)
end
end
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Quantity')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Quantity')