From 8f085e02a107dd8092393935bfa1bba71d2546d2 Mon Sep 17 00:00:00 2001 From: DS Date: Fri, 4 Jun 2021 21:22:33 +0200 Subject: Add metatables to lua vectors (#11039) Add backwards-compatible metatable functions for vectors. --- builtin/game/misc.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'builtin/game/misc.lua') diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index fcb86146d..c13a583f0 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -119,13 +119,12 @@ end function core.get_position_from_hash(hash) - local pos = {} - pos.x = (hash % 65536) - 32768 + local x = (hash % 65536) - 32768 hash = math.floor(hash / 65536) - pos.y = (hash % 65536) - 32768 + local y = (hash % 65536) - 32768 hash = math.floor(hash / 65536) - pos.z = (hash % 65536) - 32768 - return pos + local z = (hash % 65536) - 32768 + return vector.new(x, y, z) end @@ -215,7 +214,7 @@ function core.is_area_protected(minp, maxp, player_name, interval) local y = math.floor(yf + 0.5) for xf = minp.x, maxp.x, d.x do local x = math.floor(xf + 0.5) - local pos = {x = x, y = y, z = z} + local pos = vector.new(x, y, z) if core.is_protected(pos, player_name) then return pos end -- cgit v1.2.3