From b5649d3fd4b734e0a9e3309eaa1924b7f9fbaa6c Mon Sep 17 00:00:00 2001 From: Robert Machmer Date: Mon, 21 Dec 2015 00:32:17 +0100 Subject: [PATCH] Add parameter for specifying node names --- Graphoon/Graph.lua | 4 ++-- Graphoon/Node.lua | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Graphoon/Graph.lua b/Graphoon/Graph.lua index 71289bf..815b1db 100644 --- a/Graphoon/Graph.lua +++ b/Graphoon/Graph.lua @@ -72,9 +72,9 @@ function Graph.new() -- @param anchor - Wether the node should be locked in place or not (optional). -- @param ... - Additional parameters (useful when a custom Node class is used). -- - function self:addNode( id, x, y, anchor, ... ) + function self:addNode( id, name, x, y, anchor, ... ) assert( not nodes[id], "Node IDs must be unique." ); - nodes[id] = Node.new( id, x, y, anchor, ... ); + nodes[id] = Node.new( id, name, x, y, anchor, ... ); return nodes[id]; end diff --git a/Graphoon/Node.lua b/Graphoon/Node.lua index 6180ec7..b5ce2c2 100644 --- a/Graphoon/Node.lua +++ b/Graphoon/Node.lua @@ -17,7 +17,7 @@ local DEFAULT_MASS = 3; -- @param y - The y coordinate the Node should be spawned at (optional). -- @param anchor - Wether the node should be locked in place or not (optional). -- -function Node.new( id, x, y, anchor ) +function Node.new( id, name, x, y, anchor ) local self = {}; local px, py = x or 0, y or 0; @@ -143,6 +143,10 @@ function Node.new( id, x, y, anchor ) return mass; end + function self:getName() + return name; + end + return self; end