From faf9e2824f2a3aa8385ac0b3f0bc7fbf78049eba Mon Sep 17 00:00:00 2001 From: octacian Date: Wed, 8 Mar 2017 17:38:41 -0800 Subject: [PATCH] Remove after decimal before saving positions Adds helper function, spawnpoint.pos_clean, to strip off everything past the decimal point when saving a new spawnpoint position. --- init.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 49f9d27..3d9e6b8 100644 --- a/init.lua +++ b/init.lua @@ -15,6 +15,15 @@ end -- HELPER FUNCTIONS -- ---------------------- +-- [function] Clean Position +function spawnpoint.pos_clean(pos) + pos.x = math.floor(pos.x) + pos.y = math.floor(pos.y) + pos.z = math.floor(pos.z) + + return pos +end + -- [function] Load function spawnpoint.load() local res = io.open(path, "r"):read("*all") @@ -35,7 +44,7 @@ function spawnpoint.set(pos) end if type(pos) == "table" then - spawnpoint.pos = pos + spawnpoint.pos = spawnpoint.pos_clean(pos) end end