aboutsummaryrefslogtreecommitdiff
path: root/builtin/game/misc.lua
diff options
context:
space:
mode:
authorDS <vorunbekannt75@web.de>2021-06-04 21:22:33 +0200
committerGitHub <noreply@github.com>2021-06-04 21:22:33 +0200
commit8f085e02a107dd8092393935bfa1bba71d2546d2 (patch)
tree977942563431784d65b5f5066d04669d522600e6 /builtin/game/misc.lua
parente15cae9fa0f99f597f349a7ba07d149cd91cc2d8 (diff)
downloadminetest-8f085e02a107dd8092393935bfa1bba71d2546d2.tar.gz
minetest-8f085e02a107dd8092393935bfa1bba71d2546d2.tar.bz2
minetest-8f085e02a107dd8092393935bfa1bba71d2546d2.zip
Add metatables to lua vectors (#11039)
Add backwards-compatible metatable functions for vectors.
Diffstat (limited to 'builtin/game/misc.lua')
-rw-r--r--builtin/game/misc.lua11
1 files changed, 5 insertions, 6 deletions
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