Add option for non-jumpable fences and walls
authormbartlett21 <29034492+mbartlett21@users.noreply.github.com>
Mon, 16 Sep 2019 20:38:02 +0000 (06:38 +1000)
committerParamat <paramat@users.noreply.github.com>
Mon, 16 Sep 2019 20:38:02 +0000 (21:38 +0100)
Add an option, default disabled, to extend the collision boxes upwards.

minetest.conf.example
mods/default/functions.lua
mods/doors/init.lua
mods/walls/init.lua
settingtypes.txt

index d1da0ff845d47b6688734d0a3bafdbd41fa486dc..f599ca7a0e0986fce242e4ffbbefa66a12ad2ea8 100644 (file)
@@ -60,6 +60,9 @@ default:torch 99,default:cobble 99
 # Default value is true.
 #enable_bed_night_skip = true
 
+# If enabled, fences and walls cannot be jumped over.
+#enable_fence_tall = false
+
 # Whether the engine's spawn search, which does not check for a suitable
 # starting biome, is used.
 # Default value is false.
index 0f3cb764ab088c6a603fa548c2bda689f6b8f385..2a4fdfeb199b626dfc8f86c61a4116c2ddfc5ec4 100644 (file)
@@ -273,6 +273,7 @@ end
 --
 -- Fence registration helper
 --
+local fence_collision_extra = minetest.settings:get_bool("enable_fence_tall") and 3/8 or 0
 
 function default.register_fence(name, def)
        minetest.register_craft({
@@ -291,17 +292,27 @@ function default.register_fence(name, def)
                drawtype = "nodebox",
                node_box = {
                        type = "connected",
-                       fixed = {{-1/8, -1/2, -1/8, 1/8, 1/2, 1/8}},
+                       fixed = {-1/8, -1/2, -1/8, 1/8, 1/2, 1/8},
                        -- connect_top =
                        -- connect_bottom =
-                       connect_front = {{-1/16,3/16,-1/2,1/16,5/16,-1/8},
-                               {-1/16,-5/16,-1/2,1/16,-3/16,-1/8}},
-                       connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16},
-                               {-1/2,-5/16,-1/16,-1/8,-3/16,1/16}},
-                       connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2},
-                               {-1/16,-5/16,1/8,1/16,-3/16,1/2}},
-                       connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16},
-                               {1/8,-5/16,-1/16,1/2,-3/16,1/16}},
+                       connect_front = {{-1/16,  3/16, -1/2,   1/16,  5/16, -1/8 },
+                                        {-1/16, -5/16, -1/2,   1/16, -3/16, -1/8 }},
+                       connect_left =  {{-1/2,   3/16, -1/16, -1/8,   5/16,  1/16},
+                                        {-1/2,  -5/16, -1/16, -1/8,  -3/16,  1/16}},
+                       connect_back =  {{-1/16,  3/16,  1/8,   1/16,  5/16,  1/2 },
+                                        {-1/16, -5/16,  1/8,   1/16, -3/16,  1/2 }},
+                       connect_right = {{ 1/8,   3/16, -1/16,  1/2,   5/16,  1/16},
+                                        { 1/8,  -5/16, -1/16,  1/2,  -3/16,  1/16}}
+               },
+               collision_box = {
+                       type = "connected",
+                       fixed = {-1/8, -1/2, -1/8, 1/8, 1/2 + fence_collision_extra, 1/8},
+                       -- connect_top =
+                       -- connect_bottom =
+                       connect_front = {-1/8, -1/2, -1/2,  1/8, 1/2 + fence_collision_extra, -1/8},
+                       connect_left =  {-1/2, -1/2, -1/8, -1/8, 1/2 + fence_collision_extra,  1/8},
+                       connect_back =  {-1/8, -1/2,  1/8,  1/8, 1/2 + fence_collision_extra,  1/2},
+                       connect_right = { 1/8, -1/2, -1/8,  1/2, 1/2 + fence_collision_extra,  1/8}
                },
                connects_to = {"group:fence", "group:wood", "group:tree", "group:wall"},
                inventory_image = fence_texture,
@@ -349,24 +360,28 @@ function default.register_fence_rail(name, def)
                drawtype = "nodebox",
                node_box = {
                        type = "connected",
-                       fixed = {
-                               {-1/16,  3/16, -1/16, 1/16,  5/16, 1/16},
-                               {-1/16, -3/16, -1/16, 1/16, -5/16, 1/16}
-                       },
+                       fixed = {{-1/16,  3/16, -1/16, 1/16,  5/16, 1/16},
+                                {-1/16, -3/16, -1/16, 1/16, -5/16, 1/16}},
+                       -- connect_top =
+                       -- connect_bottom =
+                       connect_front = {{-1/16,  3/16, -1/2,   1/16,  5/16, -1/16},
+                                        {-1/16, -5/16, -1/2,   1/16, -3/16, -1/16}},
+                       connect_left =  {{-1/2,   3/16, -1/16, -1/16,  5/16,  1/16},
+                                        {-1/2,  -5/16, -1/16, -1/16, -3/16,  1/16}},
+                       connect_back =  {{-1/16,  3/16,  1/16,  1/16,  5/16,  1/2 },
+                                        {-1/16, -5/16,  1/16,  1/16, -3/16,  1/2 }},
+                       connect_right = {{ 1/16,  3/16, -1/16,  1/2,   5/16,  1/16},
+                                        { 1/16, -5/16, -1/16,  1/2,  -3/16,  1/16}}
+               },
+               collision_box = {
+                       type = "connected",
+                       fixed = {-1/8, -1/2, -1/8, 1/8, 1/2 + fence_collision_extra, 1/8},
                        -- connect_top =
                        -- connect_bottom =
-                       connect_front = {
-                               {-1/16,  3/16, -1/2, 1/16,  5/16, -1/16},
-                               {-1/16, -5/16, -1/2, 1/16, -3/16, -1/16}},
-                       connect_left = {
-                               {-1/2,  3/16, -1/16, -1/16,  5/16, 1/16},
-                               {-1/2, -5/16, -1/16, -1/16, -3/16, 1/16}},
-                       connect_back = {
-                               {-1/16,  3/16, 1/16, 1/16,  5/16, 1/2},
-                               {-1/16, -5/16, 1/16, 1/16, -3/16, 1/2}},
-                       connect_right = {
-                               {1/16,  3/16, -1/16, 1/2,  5/16, 1/16},
-                               {1/16, -5/16, -1/16, 1/2, -3/16, 1/16}},
+                       connect_front = {-1/8, -1/2, -1/2,  1/8, 1/2 + fence_collision_extra, -1/8},
+                       connect_left =  {-1/2, -1/2, -1/8, -1/8, 1/2 + fence_collision_extra,  1/8},
+                       connect_back =  {-1/8, -1/2,  1/8,  1/8, 1/2 + fence_collision_extra,  1/2},
+                       connect_right = { 1/8, -1/2, -1/8,  1/2, 1/2 + fence_collision_extra,  1/8}
                },
                connects_to = {"group:fence", "group:wall"},
                inventory_image = fence_rail_texture,
index ed686213329c5a2e33e794d5b590a0a742270113..99b9e07e94371b6dfdd8f133272c3fc13681d353 100644 (file)
@@ -725,6 +725,7 @@ minetest.register_craft({
 
 
 ----fence gate----
+local fence_collision_extra = minetest.settings:get_bool("enable_fence_tall") and 3/8 or 0
 
 function doors.register_fencegate(name, def)
        local fence = {
@@ -748,7 +749,7 @@ function doors.register_fencegate(name, def)
                end,
                selection_box = {
                        type = "fixed",
-                       fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4},
+                       fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4}
                },
        }
 
@@ -774,7 +775,7 @@ function doors.register_fencegate(name, def)
        fence_closed.sound = "doors_fencegate_open"
        fence_closed.collision_box = {
                type = "fixed",
-               fixed = {-1/2, -1/2, -1/4, 1/2, 1/2, 1/4},
+               fixed = {-1/2, -1/2, -1/8, 1/2, 1/2 + fence_collision_extra, 1/8}
        }
 
        local fence_open = table.copy(fence)
@@ -784,8 +785,8 @@ function doors.register_fencegate(name, def)
        fence_open.groups.not_in_creative_inventory = 1
        fence_open.collision_box = {
                type = "fixed",
-               fixed = {{-1/2, -1/2, -1/4, -3/8, 1/2, 1/4},
-                       {-1/2, -3/8, -1/2, -3/8, 3/8, 0}},
+               fixed = {{-1/2, -1/2, -1/8, -3/8, 1/2 + fence_collision_extra, 1/8},
+                        {-1/2, -3/8, -1/2, -3/8, 3/8,                         0  }}
        }
 
        minetest.register_node(":" .. name .. "_closed", fence_closed)
index c267eba5f8a79dcd1e2940c6d24a48f85db800cd..b2a163fcac58c7f28724a7fbaee94619369e66f5 100644 (file)
@@ -2,10 +2,11 @@
 
 walls = {}
 
+local fence_collision_extra = minetest.settings:get_bool("enable_fence_tall") and 3/8 or 0
+
 -- Load support for MT game translation.
 local S = minetest.get_translator("walls")
 
-
 walls.register = function(wall_name, wall_desc, wall_texture_table, wall_mat, wall_sounds)
        --make wall_texture_table paramenter backwards compatible for mods passing single texture
        if type(wall_texture_table) ~= "table" then
@@ -17,12 +18,22 @@ walls.register = function(wall_name, wall_desc, wall_texture_table, wall_mat, wa
                drawtype = "nodebox",
                node_box = {
                        type = "connected",
-                       fixed = {{-1/4, -1/2, -1/4, 1/4, 1/2, 1/4}},
+                       fixed = {-1/4, -1/2, -1/4, 1/4, 1/2, 1/4},
+                       -- connect_bottom =
+                       connect_front = {-3/16, -1/2, -1/2,  3/16, 3/8, -1/4},
+                       connect_left = {-1/2, -1/2, -3/16, -1/4, 3/8,  3/16},
+                       connect_back = {-3/16, -1/2,  1/4,  3/16, 3/8,  1/2},
+                       connect_right = { 1/4, -1/2, -3/16,  1/2, 3/8,  3/16},
+               },
+               collision_box = {
+                       type = "connected",
+                       fixed = {-1/4, -1/2, -1/4, 1/4, 1/2 + fence_collision_extra, 1/4},
+                       -- connect_top =
                        -- connect_bottom =
-                       connect_front = {{-3/16, -1/2, -1/2,  3/16, 3/8, -1/4}},
-                       connect_left = {{-1/2, -1/2, -3/16, -1/4, 3/8,  3/16}},
-                       connect_back = {{-3/16, -1/2,  1/4,  3/16, 3/8,  1/2}},
-                       connect_right = {{ 1/4, -1/2, -3/16,  1/2, 3/8,  3/16}},
+                       connect_front = {-1/4,-1/2,-1/2,1/4,1/2 + fence_collision_extra,-1/4},
+                       connect_left = {-1/2,-1/2,-1/4,-1/4,1/2 + fence_collision_extra,1/4},
+                       connect_back = {-1/4,-1/2,1/4,1/4,1/2 + fence_collision_extra,1/2},
+                       connect_right = {1/4,-1/2,-1/4,1/2,1/2 + fence_collision_extra,1/4},
                },
                connects_to = { "group:wall", "group:stone", "group:fence" },
                paramtype = "light",
index 6e3f4ab4d9a7623b2171d0ff236aaece46dd9a74..a0d5fead9ef886a854e7a35a27ae6c5cd5cc2df6 100644 (file)
@@ -32,6 +32,9 @@ enable_bed_respawn (Respawn at bed) bool true
 #    in beds.
 enable_bed_night_skip (Skip night when sleeping) bool true
 
+#    If enabled, fences and walls cannot be jumped over.
+enable_fence_tall (Tall fences and walls) bool false
+
 #    When TNT explodes, it destroys nearby nodes and damages nearby players.
 #    This setting is disabled by default on servers.
 enable_tnt (TNT) bool true