Skip to content

Commit 92bebf1

Browse files
committed
Moved metamethods to the class itself
1 parent 195ec42 commit 92bebf1

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

A_Star_Search/Lua/Yonaba/node.lua

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
-- A* Node class abstraction
22

3+
-- This class represents an abstraction of the A* Node.
4+
-- It should implemented with additional functions when
5+
-- writing a custom handler.
6+
7+
-- See astar.lua comment header.
8+
-- See custom handlers for reference (*_hander.lua).
9+
310
local class = require 'class'
411

512
local Node = class {g = 0, h = 0, f = 0}
6-
local Node_mt = getmetatable(Node)
7-
Node_mt.__eq = function(a, b) return a:isEqualTo(b) end
8-
Node_mt.__lt = function(a, b) return a.f < b.f end
9-
Node_mt.__tostring = function(n) return n:toString() end
13+
Node.__eq = function(a, b) return a:isEqualTo(b) end
14+
Node.__lt = function(a, b) return a.f < b.f end
15+
Node.__tostring = function(n) return n:toString() end
1016

11-
return Node
17+
return Node

0 commit comments

Comments
 (0)