banners.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. minetest.register_alias("lottother:tapestry_top", "lottblocks:banner_top")
  2. minetest.register_node("lottblocks:banner_top", {
  3. drawtype = "nodebox",
  4. description = "Banner Top",
  5. tiles = {"default_wood.png"},
  6. sunlight_propagates = true,
  7. groups = {flammable=3,oddly_breakable_by_hand=1},
  8. sounds = default.node_sound_defaults(),
  9. paramtype = "light",
  10. paramtype2 = "facedir",
  11. node_box = {
  12. type = "fixed",
  13. fixed = {
  14. {-0.6, -0.5, 0.375, 0.6, -0.375, 0.5},
  15. },
  16. },
  17. })
  18. minetest.register_craft({
  19. output = "lottblocks:banner_top",
  20. recipe = {
  21. {"default:stick", "default:stick", "default:stick"},
  22. },
  23. })
  24. local banners = {
  25. {"angmar", "Angmar", "red"},
  26. {"dunland", "Dunland", "brown"},
  27. {"dwarf", "Dwarf", "grey"},
  28. {"gondor", "Gondor", "blue"},
  29. {"lorien", "Lorien", "cyan"},
  30. {"mirkwood", "Mirkwood", "dark_green"},
  31. {"mordor", "Mordor", "black"},
  32. {"rohan", "Rohan", "orange"},
  33. {"urukhai", "Uruk Hai", "dark_grey"},
  34. }
  35. for _, row in ipairs(banners) do
  36. local name = row[1]
  37. local desc = row[2]
  38. local craft = row[3]
  39. minetest.register_alias("lottother:tapestry_" .. name, "lottblocks:banner_" .. name)
  40. minetest.register_alias("lottother:tapestry_top_" .. name, "lottblocks:banner_top_" .. name)
  41. minetest.register_node("lottblocks:banner_"..name, {
  42. drawtype = "nodebox",
  43. description = desc.." Banner",
  44. tiles = {
  45. "lottblocks_banner_"..name.."_side.png",
  46. "lottblocks_banner_"..name.."_side.png",
  47. "lottblocks_banner_"..name..".png",
  48. },
  49. groups = {oddly_breakable_by_hand=3,flammable=3},
  50. sounds = default.node_sound_defaults(),
  51. paramtype = "light",
  52. paramtype2 = "facedir",
  53. node_box = {
  54. type = "fixed",
  55. fixed = {
  56. {-0.5, 0.375, 0.4375, 0.5, 0.5, 0.5}, -- NodeBox1
  57. {-0.4375, 0.25, 0.4375, 0.4375, 0.375, 0.5}, -- NodeBox2
  58. {-0.375, 0.125, 0.4375, 0.375, 0.25, 0.5}, -- NodeBox3
  59. {-0.3125, 0, 0.4375, 0.3125, 0.125, 0.5}, -- NodeBox4
  60. {-0.25, -0.125, 0.4375, 0.25, 0.0625, 0.5}, -- NodeBox5
  61. {-0.1875, -0.25, 0.4375, 0.1875, -0.125, 0.5}, -- NodeBox6
  62. {-0.125, -0.375, 0.4375, 0.125, -0.25, 0.5}, -- NodeBox7
  63. {-0.0625, -0.5, 0.4375, 0.0625, -0.375, 0.5}, -- NodeBox8
  64. }
  65. },
  66. selection_box = {
  67. type = "fixed",
  68. fixed = {
  69. {-0.500000,-0.500000,0.437500,0.500000,1.500000,0.500000},
  70. },
  71. },
  72. on_place = function(itemstack, placer, pointed_thing)
  73. local above = pointed_thing.above
  74. if minetest.get_node({x = above.x, y = above.y + 1, z = above.z}).name ~= "air" then
  75. return itemstack
  76. end
  77. local fdir = 0
  78. local placer_pos = placer:getpos()
  79. if placer_pos then
  80. dir = {
  81. x = above.x - placer_pos.x,
  82. y = above.y - placer_pos.y,
  83. z = above.z - placer_pos.z
  84. }
  85. fdir = minetest.dir_to_facedir(dir)
  86. end
  87. minetest.add_node(above, {name = "lottblocks:banner_"..name, param2 = fdir})
  88. minetest.add_node({x = above.x, y = above.y + 1, z = above.z}, {name = "lottblocks:banner_top_"..name,param2 = fdir})
  89. if not minetest.setting_getbool("creative_mode") then
  90. itemstack:take_item()
  91. end
  92. return itemstack
  93. end,
  94. on_destruct = function(pos)
  95. local p = {x=pos.x, y=pos.y+1, z=pos.z}
  96. minetest.remove_node(p)
  97. end
  98. })
  99. minetest.register_node("lottblocks:banner_top_"..name, {
  100. drawtype = "nodebox",
  101. description = desc.." Banner Top",
  102. tiles = {
  103. "lottblocks_banner_"..name.."_side.png",
  104. "lottblocks_banner_"..name.."_side.png",
  105. "lottblocks_banner_top_"..name..".png",
  106. },
  107. groups = {flammable=3, not_in_creative_inventory=1},
  108. sounds = default.node_sound_defaults(),
  109. paramtype = "light",
  110. paramtype2 = "facedir",
  111. drop = '',
  112. pointable = false,
  113. node_box = {
  114. type = "fixed",
  115. fixed = {
  116. {-0.500000,-0.500000,0.437500,0.500000,0.500000,0.500000},
  117. },
  118. },
  119. })
  120. minetest.register_craft({
  121. output = "lottblocks:banner_" .. name,
  122. recipe = {
  123. {"lottblocks:banner_top"},
  124. {"wool:" .. craft},
  125. {"wool:" .. craft},
  126. },
  127. })
  128. end