Advertisement
TumeniNodes

connect point changes

Jun 27th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.15 KB | None | 0 0
  1. --
  2. -- Fence registration helper
  3. --
  4.  
  5. function default.register_fence(name, def)
  6.     minetest.register_craft({
  7.         output = name .. " 4",
  8.         recipe = {
  9.             { def.material, 'group:stick', def.material },
  10.             { def.material, 'group:stick', def.material },
  11.         }
  12.     })
  13.  
  14.     local fence_texture = "default_fence_overlay.png^" .. def.texture ..
  15.             "^default_fence_overlay.png^[makealpha:255,126,126"
  16.     -- Allow almost everything to be overridden
  17.     local default_fields = {
  18.         paramtype = "light",
  19.         drawtype = "nodebox",
  20.         node_box = {
  21.             type = "connected",
  22.             fixed = {{-1/8, -1/2, -1/8, 1/8, 1/2, 1/8}},
  23.             -- connect_top =
  24.             -- connect_bottom =
  25.             connect_front = {{-1/16,3/16,-1/2,1/16,5/16,-1/8},
  26.                 {-1/16,-5/16,-1/2,1/16,-3/16,-1/8}},
  27.             connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16},
  28.                 {-1/2,-5/16,-1/16,-1/8,-3/16,1/16}},
  29.             connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2},
  30.                 {-1/16,-5/16,1/8,1/16,-3/16,1/2}},
  31.             connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16},
  32.                 {1/8,-5/16,-1/16,1/2,-3/16,1/16}},
  33.         },
  34.         connects_to = {"group:fence", "group:fence_rail", "group:wood", "group:tree"},
  35.         inventory_image = fence_texture,
  36.         wield_image = fence_texture,
  37.         tiles = {def.texture},
  38.         sunlight_propagates = true,
  39.         is_ground_content = false,
  40.         groups = {},
  41.     }
  42.     for k, v in pairs(default_fields) do
  43.         if def[k] == nil then
  44.             def[k] = v
  45.         end
  46.     end
  47.  
  48.     -- Always add to the fence group, even if no group provided
  49.     def.groups.fence = 1
  50.  
  51.     def.texture = nil
  52.     def.material = nil
  53.  
  54.     minetest.register_node(name, def)
  55. end
  56.  
  57.  
  58. --
  59. -- Fence rail registration helper
  60. --
  61.  
  62. function default.register_fence_rail(name, def)
  63.     minetest.register_craft({
  64.         output = name .. " 4",
  65.         recipe = {
  66.             { 'group:stick', 'group:stick', 'group:stick' },
  67.             { 'group:stick', 'group:stick', 'group:stick' },
  68.         }
  69.     })
  70.  
  71.     local fence_rail_texture = "default_fence_rail_overlay.png^" .. def.texture ..
  72.             "^default_fence_rail_overlay.png^[makealpha:255,126,126"
  73.     -- Allow almost everything to be overridden
  74.     local default_fields = {
  75.         paramtype = "light",
  76. --      paramtype2 = "facedir",
  77. --        legacy_facedir_simple = true,
  78.         drawtype = "nodebox",
  79.         node_box = {
  80.             type = "connected",
  81.             fixed = {{-0.5, 0.1875, -0.0625, 0.5, 0.3125, 0.0625},
  82.                     {-0.5, -0.3125, -0.0625, 0.5, -0.1875, 0.0625}},
  83. --          connect_top =
  84. --          connect_bottom =
  85. --          connect_front =
  86.             connect_left = {{-1/2, 3/16, -1/16, -1/8, 5/16, 1/16},
  87.                 {-1/2, -5/16, -1/16, -1/8, -3/16, 1/16}},
  88. --          connect_back =
  89.             connect_right = {{1/8, 3/16, -1/16, 1/2, 5/16, 1/16},
  90.                 {1/8, -5/16, -1/16, 1/2, -3/16, 1/16}},
  91.         },
  92.         connects_to = {"group:fence", "group:fence_rail", "group:wood", "group:tree"},
  93.         inventory_image = fence_rail_texture,
  94.         wield_image = fence_rail_texture,
  95.         tiles = {def.texture},
  96.         sunlight_propagates = true,
  97.         is_ground_content = false,
  98.         groups = {},
  99.     }
  100.     for k, v in pairs(default_fields) do
  101.         if def[k] == nil then
  102.             def[k] = v
  103.         end
  104.     end
  105.  
  106.     -- Always add to the fence rail group, even if no group provided
  107.     def.groups.fence_rail = 1
  108.  
  109.     def.texture = nil
  110.     def.material = nil
  111.  
  112.     minetest.register_node(name, def)
  113. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement