init.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. default = default or {}
  2. fencelike = fencelike or {}
  3. fencelike.modpath = minetest.get_modpath("fencelike")
  4. --
  5. -- Fence registration helper
  6. --
  7. function default.register_fence(name, def)
  8. minetest.register_craft({
  9. output = name .. " 4",
  10. recipe = {
  11. { def.material, 'group:stick', def.material },
  12. { def.material, 'group:stick', def.material },
  13. }
  14. })
  15. local fence_texture = "default_fence_overlay.png^" .. def.texture ..
  16. "^default_fence_overlay.png^[makealpha:255,126,126"
  17. -- Allow almost everything to be overridden
  18. local default_fields = {
  19. paramtype = "light",
  20. drawtype = "nodebox",
  21. node_box = {
  22. type = "connected",
  23. fixed = {{-1/8, -1/2, -1/8, 1/8, 1/2, 1/8}},
  24. -- connect_top =
  25. -- connect_bottom =
  26. connect_front = {{-1/16,3/16,-1/2,1/16,5/16,-1/8},
  27. {-1/16,-5/16,-1/2,1/16,-3/16,-1/8}},
  28. connect_left = {{-1/2,3/16,-1/16,-1/8,5/16,1/16},
  29. {-1/2,-5/16,-1/16,-1/8,-3/16,1/16}},
  30. connect_back = {{-1/16,3/16,1/8,1/16,5/16,1/2},
  31. {-1/16,-5/16,1/8,1/16,-3/16,1/2}},
  32. connect_right = {{1/8,3/16,-1/16,1/2,5/16,1/16},
  33. {1/8,-5/16,-1/16,1/2,-3/16,1/16}},
  34. },
  35. connects_to = {"group:fence", "group:wood", "group:tree"},
  36. inventory_image = fence_texture,
  37. wield_image = fence_texture,
  38. tiles = {def.texture},
  39. sunlight_propagates = true,
  40. is_ground_content = false,
  41. groups = {},
  42. }
  43. for k, v in pairs(default_fields) do
  44. if not def[k] then
  45. def[k] = v
  46. end
  47. end
  48. -- Always add to the fence group, even if no group provided
  49. def.groups.fence = 1
  50. def.texture = nil
  51. def.material = nil
  52. minetest.register_node(name, def)
  53. end