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.
master
octacian 2017-03-08 17:38:41 -08:00
parent fb42e1c504
commit faf9e2824f
1 changed files with 10 additions and 1 deletions

View File

@ -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