Anonymous

Module:Items/SourceTables: Difference between revisions

From Melvor Idle
Update for v1.3
m (Add custom separator for ItemSources)
(Update for v1.3)
Line 3: Line 3:
local Constants = require('Module:Constants')
local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Common = require('Module:Common')
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local SkillData = GameData.skillData
local Modifiers = require('Module:Modifiers')
local Magic = require('Module:Magic')
local Magic = require('Module:Magic')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
Line 131: Line 133:
end
end
-- Other costs
-- Other costs
if recipe.gpCost > 0 then
table.insert(otherCostArray, Common.getCostString({ ["items"] = {}, ["currencies"] = recipe.currencyCosts}))
table.insert(otherCostArray, Icons.GP(recipe.gpCost))
end
if recipe.scCost > 0 then
table.insert(otherCostArray, Icons.SC(recipe.scCost))
end
for j, nonShardID in ipairs(recipe.nonShardItemCosts) do
for j, nonShardID in ipairs(recipe.nonShardItemCosts) do
local nonShard = Items.getItemByID(nonShardID)
local nonShard = Items.getItemByID(nonShardID)
Line 165: Line 162:
end
end
end
end
if recipe.gpCost ~= nil and recipe.gpCost > 0 then
 
table.insert(reqSubPart, Icons.GP(recipe.GPCost))
table.insert(reqSubPart, Common.getCostString({ ["items"] = {}, ["currencies"] = recipe.currencyCosts}))
end
if recipe.scCost ~= nil and recipe.scCost > 0 then
table.insert(reqSubPart, Icons.SC(recipe.SCCost))
end
table.insert(reqPart, table.concat(reqSubPart, ', '))
table.insert(reqPart, table.concat(reqSubPart, ', '))
table.insert(qtyPart, Shared.formatnum(qty * altCost.quantityMultiplier))
table.insert(qtyPart, Shared.formatnum(qty * altCost.quantityMultiplier))
Line 180: Line 173:
-- 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, xp, recipe.itemCosts, qty, time, maxTime, specialReq, recipe.gpCost, recipe.scCost))
table.insert(tables, p.buildCreationTable(skill, lvl, xp, recipe.itemCosts, qty, time, maxTime, specialReq, recipe.currencyCosts))
end
end
end
end
Line 237: Line 230:
end
end


function p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq, gpCost, scCost)
function p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq, currencyCost)
if qty == nil then qty = 1 end
if qty == nil then qty = 1 end
local resultPart = {}
local resultPart = {}
Line 258: Line 251:
end
end
end
end
if gpCost ~= nil and gpCost > 0 then
table.insert(resultPart, '<br/>')
if currencyCost ~= nil then
table.insert(resultPart, Icons.GP(gpCost))
table.insert(resultPart, Common.getCostString({ ["items"] = {}, ["currencies"] = currencyCost }))
end
if scCost ~= nil and scCost > 0 then
table.insert(resultPart, '<br/>')
table.insert(resultPart, Icons.SC(scCost))
end
end
else
else
Line 627: Line 616:
if Shared.contains(SkillData.Fishing.junkItemIDs, item.id) then
if Shared.contains(SkillData.Fishing.junkItemIDs, item.id) then
table.insert(lineArray, Icons.Icon({'Fishing', type='skill', notext=true}) .. ' [[Fishing#Junk|Junk]]')
table.insert(lineArray, Icons.Icon({'Fishing', type='skill', notext=true}) .. ' [[Fishing#Junk|Junk]]')
-- Specials
elseif GameData.getEntityByProperty(SkillData.Fishing.specialItems, 'itemID', item.id) ~= nil then
table.insert(lineArray, Icons.Icon({'Fishing', type='skill', notext=true}) .. ' [[Fishing#Special|Special]]')
elseif item.id == SkillData.Fishing.lostChestItem then
elseif item.id == SkillData.Fishing.lostChestItem then
table.insert(lineArray, Icons._SkillReq(SkillData.Fishing.name, 100))
table.insert(lineArray, Icons._SkillReq(SkillData.Fishing.name, 100))
end
-- Specials
for i, specialItem in ipairs(SkillData.Fishing.specialItems) do
if GameData.getEntityByProperty(specialItem.drops, 'itemID', item.id) ~= nil then
table.insert(lineArray, Icons.Icon({'Fishing', type='skill', notext=true}) .. ' [[Fishing#Special|Special]]')
end
end
end


Line 973: Line 965:
local fishTotWeight, fishItem = 0, nil
local fishTotWeight, fishItem = 0, nil
for i, specialItem in ipairs(SkillData.Fishing.specialItems) do
for i, specialItem in ipairs(SkillData.Fishing.specialItems) do
if specialItem.itemID == item.id then
for f, drop in ipairs(specialItem.drops) do
fishItem = specialItem
if drop.itemID == item.id then
fishItem = drop
end
fishTotWeight = fishTotWeight + drop.weight
end
end
fishTotWeight = fishTotWeight + specialItem.weight
end
end
if fishItem ~= nil then
if fishItem ~= nil then
Line 1,082: Line 1,076:
local upgrade = GameData.getEntityByProperty('itemUpgrades', 'upgradedItemID', item.id)
local upgrade = GameData.getEntityByProperty('itemUpgrades', 'upgradedItemID', item.id)
if upgrade ~= nil then
if upgrade ~= nil then
local upgradeCost = {}
local upgradeCost = Common.getCostString({
for i, itemCost in ipairs(upgrade.itemCosts) do
["items"] = upgrade.itemCosts,
local costItem = Items.getItemByID(itemCost.id)
["currencies"] = upgrade.currencyCosts
if costItem ~= nil then
})
table.insert(upgradeCost, Icons.Icon({costItem.name, type='item', qty=itemCost.quantity}))
 
end
end
if type(upgrade.gpCost) == 'number' and upgrade.gpCost > 0 then
table.insert(upgradeCost, Icons.GP(upgrade.gpCost))
end
if type(upgrade.scCost) == 'number' and upgrade.scCost > 0 then
table.insert(upgradeCost, Icons.SC(upgrade.scCost))
end
table.insert(resultPart, '{| class="wikitable"\r\n|-\r\n!colspan="2"|[[Upgrading Items|Item Upgrade]]')
table.insert(resultPart, '{| class="wikitable"\r\n|-\r\n!colspan="2"|[[Upgrading Items|Item Upgrade]]')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Materials\r\n|')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Materials\r\n|')
table.insert(resultPart, table.concat(upgradeCost, '<br/>'))
table.insert(resultPart, upgradeCost)
table.insert(resultPart, '\r\n|}')
table.insert(resultPart, '\r\n|}')
end
end
Line 1,261: Line 1,247:


for i, item in ipairs(itemArray) do
for i, item in ipairs(itemArray) do
local passiveDesc = item.customDescription or Constants.getModifiersText(item.modifiers, false)
local passiveDesc = item.customDescription or Modifiers.getModifiersText(item.modifiers, false, false, 10)
table.insert(resultPart, '|-\r\n')
table.insert(resultPart, '|-\r\n')
table.insert(resultPart, '! '..Icons.Icon({item.name, type='item', notext='true'})..'\r\n! '..Icons.Icon({item.name, type='item', noicon=true})..'\r\n')
table.insert(resultPart, '! '..Icons.Icon({item.name, type='item', notext='true'})..'\r\n! '..Icons.Icon({item.name, type='item', noicon=true})..'\r\n')