From a7d766749167712b5eb4ac35631934932b04b4b7 Mon Sep 17 00:00:00 2001 From: BenDol Date: Sun, 1 Jun 2014 18:11:52 +1200 Subject: [PATCH] Added gamelib for Position functions. --- modules/gamelib/gamelib.otmod | 1 + modules/gamelib/position.lua | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 modules/gamelib/position.lua diff --git a/modules/gamelib/gamelib.otmod b/modules/gamelib/gamelib.otmod index 0d130168..ae1c3dd2 100644 --- a/modules/gamelib/gamelib.otmod +++ b/modules/gamelib/gamelib.otmod @@ -12,6 +12,7 @@ Module dofile 'protocol' dofile 'protocollogin' dofile 'protocolgame' + dofile 'position' dofile 'game' dofile 'creature' diff --git a/modules/gamelib/position.lua b/modules/gamelib/position.lua new file mode 100644 index 00000000..e0b7d8a5 --- /dev/null +++ b/modules/gamelib/position.lua @@ -0,0 +1,21 @@ +Position = {} + +function Position.equals(pos1, pos2) + return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z +end + +function Position.greaterThan(pos1, pos2, orEqualTo) + if orEqualTo then + return pos1.x >= pos2.x or pos1.y >= pos2.y or pos1.z >= pos2.z + else + return pos1.x > pos2.x or pos1.y > pos2.y or pos1.z > pos2.z + end +end + +function Position.lessThan(pos1, pos2, orEqualTo) + if orEqualTo then + return pos1.x <= pos2.x or pos1.y <= pos2.y or pos1.z <= pos2.z + else + return pos1.x < pos2.x or pos1.y < pos2.y or pos1.z < pos2.z + end +end \ No newline at end of file