Add fence rails
authorTumeniNodes <tumeninodes@gmail.com>
Sat, 7 Jul 2018 18:03:33 +0000 (14:03 -0400)
committerParamat <paramat@users.noreply.github.com>
Sat, 7 Jul 2018 18:03:33 +0000 (19:03 +0100)
Dedicated fence rail textures coming in a follow-up PR.

mods/default/crafting.lua
mods/default/functions.lua
mods/default/nodes.lua
mods/default/textures/default_fence_rail_overlay.png [new file with mode: 0644]
mods/walls/init.lua

index 428c0f456220a545636977f2aabc8ebf262da952..c0f2252f566f1b25e7ebac02363cae483fdfbb53 100644 (file)
@@ -1015,6 +1015,37 @@ minetest.register_craft({
 })
 
 
+minetest.register_craft({
+       type = "fuel",
+       recipe = "default:fence_rail_aspen_wood",
+       burntime = 3,
+})
+
+minetest.register_craft({
+       type = "fuel",
+       recipe = "default:fence_rail_pine_wood",
+       burntime = 4,
+})
+
+minetest.register_craft({
+       type = "fuel",
+       recipe = "default:fence_rail_wood",
+       burntime = 5,
+})
+
+minetest.register_craft({
+       type = "fuel",
+       recipe = "default:fence_rail_acacia_wood",
+       burntime = 6,
+})
+
+minetest.register_craft({
+       type = "fuel",
+       recipe = "default:fence_rail_junglewood",
+       burntime = 7,
+})
+
+
 minetest.register_craft({
        type = "fuel",
        recipe = "default:bush_stem",
index d43ab7b963b6ad409f4a907c0ccdeada83ff8fb1..5dd0d2c8b37a8e87351a4c388293d3ce3cf79ae8 100644 (file)
@@ -303,7 +303,7 @@ function default.register_fence(name, def)
                        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}},
                },
-               connects_to = {"group:fence", "group:wood", "group:tree"},
+               connects_to = {"group:fence", "group:wood", "group:tree", "group:wall"},
                inventory_image = fence_texture,
                wield_image = fence_texture,
                tiles = {def.texture},
@@ -327,6 +327,71 @@ function default.register_fence(name, def)
 end
 
 
+--
+-- Fence rail registration helper
+--
+
+function default.register_fence_rail(name, def)
+       minetest.register_craft({
+               output = name .. " 16",
+               recipe = {
+                       { def.material, def.material },
+                       { "", ""},
+                       { def.material, def.material },
+               }
+       })
+
+       local fence_rail_texture = "default_fence_rail_overlay.png^" .. def.texture ..
+                       "^default_fence_rail_overlay.png^[makealpha:255,126,126"
+       -- Allow almost everything to be overridden
+       local default_fields = {
+               paramtype = "light",
+               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}
+                       },
+                       -- 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}},
+               },
+               connects_to = {"group:fence", "group:wood", "group:tree", "group:wall"},
+               inventory_image = fence_rail_texture,
+               wield_image = fence_rail_texture,
+               tiles = {def.texture},
+               sunlight_propagates = true,
+               is_ground_content = false,
+               groups = {},
+       }
+       for k, v in pairs(default_fields) do
+               if def[k] == nil then
+                       def[k] = v
+               end
+       end
+
+       -- Always add to the fence group, even if no group provided
+       def.groups.fence = 1
+
+       def.texture = nil
+       def.material = nil
+
+       minetest.register_node(name, def)
+end
+
+
 --
 -- Leafdecay
 --
index 6b0785e275d95ef791d3ead6b2bfc146b8187c85..2ef3b93bc7f5326a1a385ec4136812e3921626dc 100644 (file)
@@ -2590,8 +2590,10 @@ minetest.register_node("default:ladder_steel", {
 default.register_fence("default:fence_wood", {
        description = "Apple Wood Fence",
        texture = "default_fence_wood.png",
-       inventory_image = "default_fence_overlay.png^default_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
-       wield_image = "default_fence_overlay.png^default_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
+       inventory_image = "default_fence_overlay.png^default_wood.png^" ..
+                               "default_fence_overlay.png^[makealpha:255,126,126",
+       wield_image = "default_fence_overlay.png^default_wood.png^" ..
+                               "default_fence_overlay.png^[makealpha:255,126,126",
        material = "default:wood",
        groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
        sounds = default.node_sound_wood_defaults()
@@ -2600,8 +2602,10 @@ default.register_fence("default:fence_wood", {
 default.register_fence("default:fence_acacia_wood", {
        description = "Acacia Wood Fence",
        texture = "default_fence_acacia_wood.png",
-       inventory_image = "default_fence_overlay.png^default_acacia_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
-       wield_image = "default_fence_overlay.png^default_acacia_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
+       inventory_image = "default_fence_overlay.png^default_acacia_wood.png^" ..
+                               "default_fence_overlay.png^[makealpha:255,126,126",
+       wield_image = "default_fence_overlay.png^default_acacia_wood.png^" ..
+                               "default_fence_overlay.png^[makealpha:255,126,126",
        material = "default:acacia_wood",
        groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
        sounds = default.node_sound_wood_defaults()
@@ -2610,8 +2614,10 @@ default.register_fence("default:fence_acacia_wood", {
 default.register_fence("default:fence_junglewood", {
        description = "Jungle Wood Fence",
        texture = "default_fence_junglewood.png",
-       inventory_image = "default_fence_overlay.png^default_junglewood.png^default_fence_overlay.png^[makealpha:255,126,126",
-       wield_image = "default_fence_overlay.png^default_junglewood.png^default_fence_overlay.png^[makealpha:255,126,126",
+       inventory_image = "default_fence_overlay.png^default_junglewood.png^" ..
+                               "default_fence_overlay.png^[makealpha:255,126,126",
+       wield_image = "default_fence_overlay.png^default_junglewood.png^" ..
+                               "default_fence_overlay.png^[makealpha:255,126,126",
        material = "default:junglewood",
        groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
        sounds = default.node_sound_wood_defaults()
@@ -2620,8 +2626,10 @@ default.register_fence("default:fence_junglewood", {
 default.register_fence("default:fence_pine_wood", {
        description = "Pine Wood Fence",
        texture = "default_fence_pine_wood.png",
-       inventory_image = "default_fence_overlay.png^default_pine_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
-       wield_image = "default_fence_overlay.png^default_pine_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
+       inventory_image = "default_fence_overlay.png^default_pine_wood.png^" ..
+                               "default_fence_overlay.png^[makealpha:255,126,126",
+       wield_image = "default_fence_overlay.png^default_pine_wood.png^" ..
+                               "default_fence_overlay.png^[makealpha:255,126,126",
        material = "default:pine_wood",
        groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
        sounds = default.node_sound_wood_defaults()
@@ -2630,13 +2638,75 @@ default.register_fence("default:fence_pine_wood", {
 default.register_fence("default:fence_aspen_wood", {
        description = "Aspen Wood Fence",
        texture = "default_fence_aspen_wood.png",
-       inventory_image = "default_fence_overlay.png^default_aspen_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
-       wield_image = "default_fence_overlay.png^default_aspen_wood.png^default_fence_overlay.png^[makealpha:255,126,126",
+       inventory_image = "default_fence_overlay.png^default_aspen_wood.png^" ..
+                               "default_fence_overlay.png^[makealpha:255,126,126",
+       wield_image = "default_fence_overlay.png^default_aspen_wood.png^" ..
+                               "default_fence_overlay.png^[makealpha:255,126,126",
        material = "default:aspen_wood",
        groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
        sounds = default.node_sound_wood_defaults()
 })
 
+default.register_fence_rail("default:fence_rail_wood", {
+       description = "Apple Wood Fence Rail",
+       texture = "default_wood.png",
+       inventory_image = "default_fence_rail_overlay.png^default_wood.png^" ..
+                               "default_fence_rail_overlay.png^[makealpha:255,126,126",
+       wield_image = "default_fence_rail_overlay.png^default_wood.png^" ..
+                               "default_fence_rail_overlay.png^[makealpha:255,126,126",
+       material = "default:wood",
+       groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
+       sounds = default.node_sound_wood_defaults()
+})
+
+default.register_fence_rail("default:fence_rail_acacia_wood", {
+       description = "Acacia Wood Fence Rail",
+       texture = "default_acacia_wood.png",
+       inventory_image = "default_fence_rail_overlay.png^default_acacia_wood.png^" ..
+                               "default_fence_rail_overlay.png^[makealpha:255,126,126",
+       wield_image = "default_fence_rail_overlay.png^default_acacia_wood.png^" ..
+                               "default_fence_rail_overlay.png^[makealpha:255,126,126",
+       material = "default:acacia_wood",
+       groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
+       sounds = default.node_sound_wood_defaults()
+})
+
+default.register_fence_rail("default:fence_rail_junglewood", {
+       description = "Jungle Wood Fence Rail",
+       texture = "default_junglewood.png",
+       inventory_image = "default_fence_rail_overlay.png^default_junglewood.png^" ..
+                               "default_fence_rail_overlay.png^[makealpha:255,126,126",
+       wield_image = "default_fence_rail_overlay.png^default_junglewood.png^" ..
+                               "default_fence_rail_overlay.png^[makealpha:255,126,126",
+       material = "default:junglewood",
+       groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
+       sounds = default.node_sound_wood_defaults()
+})
+
+default.register_fence_rail("default:fence_rail_pine_wood", {
+       description = "Pine Wood Fence Rail",
+       texture = "default_pine_wood.png",
+       inventory_image = "default_fence_rail_overlay.png^default_pine_wood.png^" ..
+                               "default_fence_rail_overlay.png^[makealpha:255,126,126",
+       wield_image = "default_fence_rail_overlay.png^default_pine_wood.png^" ..
+                               "default_fence_rail_overlay.png^[makealpha:255,126,126",
+       material = "default:pine_wood",
+       groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 3},
+       sounds = default.node_sound_wood_defaults()
+})
+
+default.register_fence_rail("default:fence_rail_aspen_wood", {
+       description = "Aspen Wood Fence Rail",
+       texture = "default_aspen_wood.png",
+       inventory_image = "default_fence_rail_overlay.png^default_aspen_wood.png^" ..
+                               "default_fence_rail_overlay.png^[makealpha:255,126,126",
+       wield_image = "default_fence_rail_overlay.png^default_aspen_wood.png^" ..
+                               "default_fence_rail_overlay.png^[makealpha:255,126,126",
+       material = "default:aspen_wood",
+       groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 2},
+       sounds = default.node_sound_wood_defaults()
+})
+
 minetest.register_node("default:glass", {
        description = "Glass",
        drawtype = "glasslike_framed_optional",
diff --git a/mods/default/textures/default_fence_rail_overlay.png b/mods/default/textures/default_fence_rail_overlay.png
new file mode 100644 (file)
index 0000000..4da47ae
Binary files /dev/null and b/mods/default/textures/default_fence_rail_overlay.png differ
index bee8e4658402d68e665f46788ca4ff28afe467e8..564d6df01bb6e2f3c6275e28ca59cd037ab186dd 100644 (file)
@@ -14,7 +14,7 @@ walls.register = function(wall_name, wall_desc, wall_texture, wall_mat, wall_sou
                        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}},
                },
-               connects_to = { "group:wall", "group:stone" },
+               connects_to = { "group:wall", "group:stone", "group:fence" },
                paramtype = "light",
                is_ground_content = false,
                tiles = { wall_texture, },