init.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. local colours = {
  2. {"black", "Black", "#000000b0"},
  3. {"blue", "Blue", "#015dbb70"},
  4. {"brown", "Brown", "#a78c4570"},
  5. {"cyan", "Cyan", "#01ffd870"},
  6. {"dark_green", "Dark Green", "#005b0770"},
  7. {"dark_grey", "Dark Grey", "#303030b0"},
  8. {"green", "Green", "#61ff0170"},
  9. {"grey", "Grey", "#5b5b5bb0"},
  10. {"magenta", "Magenta", "#ff05bb70"},
  11. {"orange", "Orange", "#ff840170"},
  12. {"pink", "Pink", "#ff65b570"},
  13. {"red", "Red", "#ff000070"},
  14. {"violet", "Violet", "#2000c970"},
  15. {"white", "White", "#abababc0"},
  16. {"yellow", "Yellow", "#e3ff0070"},
  17. }
  18. local stairs_mod = minetest.get_modpath("stairs")
  19. local stairsplus_mod = minetest.get_modpath("moreblocks")
  20. and minetest.global_exists("stairsplus")
  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. --[[
  42. elseif stairs_mod and stairs.mod then
  43. stairs.register_all(name, nodename,
  44. def.groups,
  45. def.tiles,
  46. def.description,
  47. def.sounds,
  48. def.alpha
  49. )
  50. ]]
  51. elseif stairs_mod and not stairs.mod then
  52. stairs.register_stair_and_slab(name, nodename,
  53. def.groups,
  54. def.tiles,
  55. ("%s Stair"):format(def.description),
  56. ("%s Slab"):format(def.description),
  57. def.sounds
  58. )
  59. end
  60. end
  61. end
  62. for i = 1, #colours, 1 do
  63. -- wood
  64. cblocks_stairs("cblocks:wood_" .. colours[i][1], {
  65. description = colours[i][2] .. " Wooden Planks",
  66. tiles = {"default_wood.png^[colorize:" .. colours[i][3]},
  67. paramtype = "light",
  68. is_ground_content = false,
  69. groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
  70. sounds = default.node_sound_wood_defaults(),
  71. })
  72. minetest.register_craft({
  73. output = "cblocks:wood_".. colours[i][1] .. " 2",
  74. recipe = {
  75. {"group:wood","group:wood", "dye:" .. colours[i][1]},
  76. }
  77. })
  78. -- stone brick
  79. cblocks_stairs("cblocks:stonebrick_" .. colours[i][1], {
  80. description = colours[i][2] .. " Stone Brick",
  81. tiles = {"default_stone_brick.png^[colorize:" .. colours[i][3]},
  82. paramtype = "light",
  83. is_ground_content = false,
  84. groups = {cracky = 2, stone = 1},
  85. sounds = default.node_sound_stone_defaults(),
  86. })
  87. minetest.register_craft({
  88. output = "cblocks:stonebrick_".. colours[i][1] .. " 2",
  89. recipe = {
  90. {"default:stonebrick","default:stonebrick", "dye:" .. colours[i][1]},
  91. }
  92. })
  93. -- glass (no stairs because they dont support transparant nodes)
  94. minetest.register_node("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. minetest.register_craft({
  106. output = "cblocks:glass_".. colours[i][1] .. " 2",
  107. recipe = {
  108. {"default:glass","default:glass", "dye:" .. colours[i][1]},
  109. }
  110. })
  111. end
  112. -- add lucky blocks
  113. if minetest.get_modpath("lucky_block") then
  114. lucky_block:add_blocks({
  115. {"dro", {"cblocks:wood_"}, 10, true},
  116. {"dro", {"cblocks:stonebrick_"}, 10, true},
  117. {"dro", {"cblocks:glass_"}, 10, true},
  118. {"exp"},
  119. })
  120. end
  121. print ("[MOD] Cblocks loaded")