Builtin/falling: Add fallback vector in case of nil 'wallmounted to dir'
authorparamat <mat.gregory@virginmedia.com>
Sun, 2 Oct 2016 21:04:47 +0000 (22:04 +0100)
committerparamat <mat.gregory@virginmedia.com>
Mon, 3 Oct 2016 00:56:08 +0000 (01:56 +0100)
The fallback vector is in case 'wallmounted to dir' is nil due
to voxelmanip placing a wallmounted node without resetting a
pre-existing param2 value that is out-of-range for wallmounted.
The fallback vector corresponds to param2 = 0.

builtin/game/falling.lua

index fa7ff24bce5b0d7146553f7c6c2382c983deaffd..4b16a05865f6592c2c91d92b3c6f4532b124d64a 100644 (file)
@@ -130,7 +130,11 @@ function check_attached_node(p, n)
        local def = core.registered_nodes[n.name]
        local d = {x = 0, y = 0, z = 0}
        if def.paramtype2 == "wallmounted" then
-               d = core.wallmounted_to_dir(n.param2)
+               -- The fallback vector here is in case 'wallmounted to dir' is nil due
+               -- to voxelmanip placing a wallmounted node without resetting a
+               -- pre-existing param2 value that is out-of-range for wallmounted.
+               -- The fallback vector corresponds to param2 = 0.
+               d = core.wallmounted_to_dir(n.param2) or {x = 0, y = 1, z = 0}
        else
                d.y = -1
        end