393
edits
No edit summary |
No edit summary |
||
Line 93: | Line 93: | ||
-- Constants for layout | -- Constants for layout | ||
local baseX = | local baseX = 500 -- Center of the tree horizontally | ||
local baseY = 50 -- | local baseY = 50 -- Start Y position (top of the screen) | ||
local verticalSpacing = 200 -- Distance between levels (Y-axis) | local verticalSpacing = 200 -- Distance between levels (Y-axis) | ||
local horizontalSpacing = | local horizontalSpacing = 200 -- Distance between nodes at the same level (X-axis) | ||
-- Count nodes per level for horizontal positioning | -- Count nodes per level for horizontal positioning | ||
Line 123: | Line 123: | ||
-- Track positions for each node | -- Track positions for each node | ||
local nodePositions = {} | local nodePositions = {} | ||
-- Keep track of how many nodes we've placed on each level | |||
local nodeIndexPerLevel = {} | |||
-- Position each node dynamically | -- Position each node dynamically | ||
for i, node in ipairs(skillNodes) do | for i, node in ipairs(skillNodes) do | ||
local level = nodeLevels[node.name] | local level = nodeLevels[node.name] | ||
nodeIndexPerLevel[level] = (nodeIndexPerLevel[level] or 0) + 1 | |||
local indexInLevel = | local indexInLevel = nodeIndexPerLevel[level] | ||
-- Calculate X and Y positions for this node | -- Calculate X and Y positions for this node | ||
local nodesAtThisLevel = nodesPerLevel[level] | |||
local xPos = baseX + (indexInLevel - nodesAtThisLevel / 2) * horizontalSpacing | local xPos = baseX + (indexInLevel - nodesAtThisLevel / 2) * horizontalSpacing | ||
local yPos = baseY + level * verticalSpacing | local yPos = baseY + level * verticalSpacing |
edits