init.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. -- walls/init.lua
  2. walls = {}
  3. local fence_collision_extra = minetest.settings:get_bool("enable_fence_tall") and 3/8 or 0
  4. -- Load support for MT game translation.
  5. local S = minetest.get_translator("walls")
  6. walls.register = function(wall_name, wall_desc, wall_texture_table, wall_mat, wall_sounds)
  7. --make wall_texture_table paramenter backwards compatible for mods passing single texture
  8. if type(wall_texture_table) ~= "table" then
  9. wall_texture_table = { wall_texture_table }
  10. end
  11. -- inventory node, and pole-type wall start item
  12. minetest.register_node(wall_name, {
  13. description = wall_desc,
  14. drawtype = "nodebox",
  15. node_box = {
  16. type = "connected",
  17. fixed = {-1/4, -1/2, -1/4, 1/4, 1/2, 1/4},
  18. -- connect_bottom =
  19. connect_front = {-3/16, -1/2, -1/2, 3/16, 3/8, -1/4},
  20. connect_left = {-1/2, -1/2, -3/16, -1/4, 3/8, 3/16},
  21. connect_back = {-3/16, -1/2, 1/4, 3/16, 3/8, 1/2},
  22. connect_right = { 1/4, -1/2, -3/16, 1/2, 3/8, 3/16},
  23. },
  24. collision_box = {
  25. type = "connected",
  26. fixed = {-1/4, -1/2, -1/4, 1/4, 1/2 + fence_collision_extra, 1/4},
  27. -- connect_top =
  28. -- connect_bottom =
  29. connect_front = {-1/4,-1/2,-1/2,1/4,1/2 + fence_collision_extra,-1/4},
  30. connect_left = {-1/2,-1/2,-1/4,-1/4,1/2 + fence_collision_extra,1/4},
  31. connect_back = {-1/4,-1/2,1/4,1/4,1/2 + fence_collision_extra,1/2},
  32. connect_right = {1/4,-1/2,-1/4,1/2,1/2 + fence_collision_extra,1/4},
  33. },
  34. connects_to = { "group:wall", "group:stone", "group:fence" },
  35. paramtype = "light",
  36. is_ground_content = false,
  37. tiles = wall_texture_table,
  38. walkable = true,
  39. groups = { cracky = 3, wall = 1, stone = 2 },
  40. sounds = wall_sounds,
  41. })
  42. -- crafting recipe
  43. -- HACK:
  44. -- Walls have no crafts, when register new wall via API from another mod, but in the same namespace (`walls`).
  45. -- So we should remove `":"` at the beginning of the name.
  46. if wall_name:sub(1, 1) == ":" then
  47. wall_name = wall_name:sub(2)
  48. end
  49. minetest.register_craft({
  50. output = wall_name .. " 6",
  51. recipe = {
  52. { "", "", "" },
  53. { wall_mat, wall_mat, wall_mat},
  54. { wall_mat, wall_mat, wall_mat},
  55. }
  56. })
  57. end
  58. walls.register("walls:cobble", S("Cobblestone Wall"), {"default_cobble.png"},
  59. "default:cobble", default.node_sound_stone_defaults())
  60. walls.register("walls:mossycobble", S("Mossy Cobblestone Wall"), {"default_mossycobble.png"},
  61. "default:mossycobble", default.node_sound_stone_defaults())
  62. walls.register("walls:desertcobble", S("Desert Cobblestone Wall"), {"default_desert_cobble.png"},
  63. "default:desert_cobble", default.node_sound_stone_defaults())