Module:Sandbox/SkillTree: Difference between revisions
From Melvor Idle
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
local GameData = require('Module:GameData') | local GameData = require('Module:GameData') | ||
function p.getSkillTreeNodes(checkFunc) | function p.getSkillTreeNodes(checkFunc) | ||
Line 23: | Line 22: | ||
end | end | ||
end | end | ||
end | |||
return nodes | |||
end | |||
function p.getSkillTree(skillName) | |||
mw.log(GameData.skillData) | |||
local skillData = GameData.skillData[skillName] | |||
if not skillData then return nil end | |||
local nodes = {} | |||
for _, node in ipairs(skillData.skillTrees[1].nodes) do | |||
table.insert(nodes, node) | |||
end | end | ||
return nodes | return nodes |
Revision as of 13:02, 31 August 2024
Documentation for this module may be created at Module:Sandbox/SkillTree/doc
local p = {}
local GameData = require('Module:GameData')
function p.getSkillTreeNodes(checkFunc)
local nodes = {}
for skillName, skillData in pairs(GameData.skillData) do
local skillTrees = skillData.skillTrees
if skillTrees then
for _, skillTree in ipairs(skillTrees) do
for _, node in ipairs(GameData.getEntities(skillTree.nodes, checkFunc)) do
local nodeCopy = {}
for k, v in pairs(node) do
nodeCopy[k] = v
end
nodeCopy.skillName = skillName
table.insert(nodes, nodeCopy)
end
end
end
end
return nodes
end
function p.getSkillTree(skillName)
mw.log(GameData.skillData)
local skillData = GameData.skillData[skillName]
if not skillData then return nil end
local nodes = {}
for _, node in ipairs(skillData.skillTrees[1].nodes) do
table.insert(nodes, node)
end
return nodes
end
return p