init.lua 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. local stairs_mod = minetest.get_modpath("stairs")
  2. local stairsplus_mod = minetest.global_exists("stairsplus")
  3. local ethereal_mod = minetest.get_modpath("ethereal")
  4. local colours = {
  5. {"black", "Black", "#000000b0"},
  6. {"blue", "Blue", "#015dbb70"},
  7. {"brown", "Brown", "#a78c4570"},
  8. {"cyan", "Cyan", "#01ffd870"},
  9. {"dark_green", "Dark Green", "#005b0770"},
  10. {"dark_grey", "Dark Grey", "#303030b0"},
  11. {"green", "Green", "#61ff0170"},
  12. {"grey", "Grey", "#5b5b5bb0"},
  13. {"magenta", "Magenta", "#ff05bb70"},
  14. {"orange", "Orange", "#ff840170"},
  15. {"pink", "Pink", "#ff65b570"},
  16. {"red", "Red", "#ff000070"},
  17. {"violet", "Violet", "#2000c970"},
  18. {"white", "White", "#abababc0"},
  19. {"yellow", "Yellow", "#e3ff0070"}
  20. }
  21. local function cblocks_stairs(nodename, def)
  22. minetest.register_node(nodename, def)
  23. if stairs_mod or stairsplus_mod then
  24. local mod, name = nodename:match("(.*):(.*)")
  25. for groupname, value in pairs(def.groups) do
  26. if groupname ~= "cracky"
  27. and groupname ~= "choppy"
  28. and groupname ~="flammable"
  29. and groupname ~="crumbly"
  30. and groupname ~="snappy" then
  31. def.groups.groupname = nil
  32. end
  33. end
  34. if stairsplus_mod then
  35. stairsplus:register_all(mod, name, nodename, {
  36. description = def.description,
  37. tiles = def.tiles,
  38. groups = def.groups,
  39. sounds = def.sounds
  40. })
  41. elseif stairs_mod and stairs
  42. and stairs.mod and stairs.mod == "redo" then
  43. stairs.register_all(name, nodename,
  44. def.groups,
  45. def.tiles,
  46. def.description,
  47. def.sounds
  48. )
  49. elseif stairs_mod and not stairs.mod then
  50. stairs.register_stair_and_slab(name, nodename,
  51. def.groups,
  52. def.tiles,
  53. ("%s Stair"):format(def.description),
  54. ("%s Slab"):format(def.description),
  55. def.sounds
  56. )
  57. end
  58. end
  59. end
  60. local function set_alias(col, name)
  61. minetest.register_alias("stairs:stair_" .. col .. "_" .. name,
  62. "stairs:stair_" .. name .. "_" .. col)
  63. minetest.register_alias("stairs:slab_" .. col .. "_" .. name,
  64. "stairs:slab_" .. name .. "_" .. col)
  65. minetest.register_alias("stairs:stair_inner_" .. col .. "_" .. name,
  66. "stairs:stair_inner_" .. name .. "_" .. col)
  67. minetest.register_alias("stairs:stair_outer_" .. col .. "_" .. name,
  68. "stairs:stair_outer_" .. name .. "_" .. col)
  69. minetest.register_alias("stairs:slope_" .. col .. "_" .. name,
  70. "stairs:slope_" .. name .. "_" .. col)
  71. end
  72. for i = 1, #colours do
  73. -- stone brick
  74. cblocks_stairs("cblocks:stonebrick_" .. colours[i][1], {
  75. description = colours[i][2] .. " Stone Brick",
  76. tiles = {"default_stone_brick.png^[colorize:" .. colours[i][3]},
  77. paramtype = "light",
  78. use_texture_alpha = "opaque",
  79. is_ground_content = false,
  80. groups = {cracky = 2, stone = 1},
  81. sounds = default.node_sound_stone_defaults(),
  82. paramtype2 = "facedir",
  83. on_place = minetest.rotate_node
  84. })
  85. minetest.register_craft({
  86. output = "cblocks:stonebrick_" .. colours[i][1] .. " 2",
  87. recipe = {
  88. {"default:stonebrick","default:stonebrick", "dye:" .. colours[i][1]}
  89. }
  90. })
  91. -- glass (no stairs unless stairs redo active because default stairs mod
  92. -- does not support transparent stairs)
  93. if stairs_mod and stairs and stairs.mod and stairs.mod == "redo" then
  94. cblocks_stairs("cblocks:glass_" .. colours[i][1], {
  95. description = colours[i][2] .. " Glass",
  96. tiles = {"cblocks.png^[colorize:" .. colours[i][3]},
  97. drawtype = "glasslike",
  98. paramtype = "light",
  99. sunlight_propagates = true,
  100. use_texture_alpha = "blend",
  101. is_ground_content = false,
  102. groups = {cracky = 3, oddly_breakable_by_hand = 3},
  103. sounds = default.node_sound_glass_defaults()
  104. })
  105. set_alias(colours[i][1], "glass")
  106. else
  107. minetest.register_node("cblocks:glass_" .. colours[i][1], {
  108. description = colours[i][2] .. " Glass",
  109. tiles = {"cblocks.png^[colorize:" .. colours[i][3]},
  110. drawtype = "glasslike",
  111. paramtype = "light",
  112. sunlight_propagates = true,
  113. use_texture_alpha = "blend",
  114. is_ground_content = false,
  115. groups = {cracky = 3, oddly_breakable_by_hand = 3},
  116. sounds = default.node_sound_glass_defaults()
  117. })
  118. end
  119. minetest.register_craft({
  120. output = "cblocks:glass_".. colours[i][1] .. " 2",
  121. recipe = {
  122. {"default:glass","default:glass", "dye:" .. colours[i][1]},
  123. }
  124. })
  125. -- wood
  126. local col = colours[i][1]
  127. -- ethereal already has yellow wood so rename to yellow2
  128. if ethereal_mod and col == "yellow" then
  129. col = "yellow2"
  130. end
  131. cblocks_stairs("cblocks:wood_" .. col, {
  132. description = colours[i][2] .. " Wooden Planks",
  133. tiles = {"default_wood.png^[colorize:" .. colours[i][3]},
  134. paramtype = "light",
  135. use_texture_alpha = "opaque",
  136. is_ground_content = false,
  137. groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
  138. sounds = default.node_sound_wood_defaults(),
  139. paramtype2 = "facedir",
  140. on_place = minetest.rotate_node
  141. })
  142. set_alias(colours[i][1], "wood")
  143. minetest.register_craft({
  144. output = "cblocks:wood_" .. col .. " 2",
  145. recipe = {
  146. {"group:wood","group:wood", "dye:" .. colours[i][1]}
  147. }
  148. })
  149. end
  150. -- add lucky blocks
  151. if minetest.get_modpath("lucky_block") then
  152. lucky_block:add_blocks({
  153. {"dro", {"cblocks:wood_"}, 10, true},
  154. {"dro", {"cblocks:stonebrick_"}, 10, true},
  155. {"dro", {"cblocks:glass_"}, 10, true},
  156. {"exp"}
  157. })
  158. end
  159. print ("[MOD] Cblocks loaded")