SHARE
TWEET

need connect point changes

TumeniNodes Jun 27th, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 = {{-1/16,3/16,-1/2,1/16,5/16,-1/8},
  86. --              {-1/16,-5/16,-1/2,1/16,-3/16,-1/8}},
  87.             connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16},
  88.                 {-1/2,5/16,-1/16,-1/8,3/16,1/16}},
  89. --          connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2},
  90. --              {-1/16,-5/16,1/8,1/16,-3/16,1/2}},
  91.             connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16},
  92.                 {1/8,5/16,-1/16,1/2,3/16,1/16}},
  93.         },
  94.         connects_to = {"group:fence", "group:fence_rail", "group:wood", "group:tree"},
  95.         inventory_image = fence_rail_texture,
  96.         wield_image = fence_rail_texture,
  97.         tiles = {def.texture},
  98.         sunlight_propagates = true,
  99.         is_ground_content = false,
  100.         groups = {},
  101.     }
  102.     for k, v in pairs(default_fields) do
  103.         if not def[k] then
  104.         if type(v) == "table" then
  105.                 def[k] = table.copy(v) else
  106.                 def[k] = v
  107.         end
  108.     end
  109. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top