bobblocks.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. -- BobBlocks mod by RabbiBob, edited by rubberduck and added into goldgem-mod
  2. local bobbs = {
  3. { "redblock", "Red BobBlock"},
  4. { "orangeblock", "Orange BobBlock"},
  5. { "yellowblock", "Yellow BobBlock"},
  6. { "greenblock", "Green BobBlock"},
  7. { "blueblock", "Blue BobBlock"},
  8. { "indigoblock", "Indigo BobBlock"},
  9. { "violetblock", "Violet BobBlock"},
  10. { "whiteblock", "White BobBlock"},
  11. { "greyblock", "Grey BobBlock"},
  12. { "pinkblock", "Pink BobBlock"},
  13. { "limeblock", "Lime BobBlock"},
  14. { "cyanblock", "Cyan BobBlock"},
  15. { "redpole", "Red BobPole"},
  16. { "orangepole", "Orange BobPole"},
  17. { "yellowpole", "Yellow BobPole"},
  18. { "greenpole", "Green BobPole"},
  19. { "bluepole", "Blue BobPole"},
  20. { "indigopole", "Indigo BobPole"},
  21. { "violetpole", "Violet BobPole"},
  22. { "whitepole", "White BobPole"},
  23. { "greypole", "Grey BobPole"},
  24. { "pinkpole", "Pink BobPole"},
  25. { "limepole", "Lime BobPole"},
  26. { "cyanpole", "Cyan BobPole"}
  27. }
  28. local orig_bobbs = { "redblock", "orangeblock", "yellowblock", "greenblock", "blueblock", "indigoblock", "violetblock", "whiteblock", "greyblock", "redpole", "orangepole", "yellowpole", "greenpole", "bluepole", "indigopole", "violetpole", "whitepole", "greypole"}
  29. local update_bobblock = function (pos, node)
  30. local nodename=""
  31. local param2=""
  32. for i in ipairs(bobbs) do
  33. local bob = bobbs[i][1]
  34. if
  35. node.name == "gold_and_gem:"..bob.."_off" then nodename = "gold_and_gem:"..bob
  36. elseif
  37. node.name == "gold_and_gem:"..bob then nodename = "gold_and_gem:"..bob.."_off"
  38. end
  39. end
  40. minetest.env:add_node(pos, {name = nodename})
  41. minetest.sound_play("bobblocks_glassblock",
  42. {pos = pos, gain = 1.0, max_hear_distance = 32,})
  43. end
  44. -- Punch Blocks
  45. local on_bobblock_punched = function (pos, node, puncher)
  46. for i in ipairs(bobbs) do
  47. local block = bobbs[i][1]
  48. if
  49. node.name == "gold_and_gem:"..block or node.name == "gold_and_gem:"..block.."_off"
  50. then
  51. update_bobblock(pos, node)
  52. end
  53. end
  54. end
  55. minetest.register_on_punchnode(on_bobblock_punched)
  56. for i in ipairs(bobbs) do
  57. local block = bobbs[i][1]
  58. local bobname = bobbs[i][2]
  59. if string.find(block, "block") then
  60. minetest.register_node("gold_and_gem:"..block, {
  61. description = bobname,
  62. drawtype = "glasslike",
  63. tile_images = {"bobblocks_"..block..".png"},
  64. inventory_image = minetest.inventorycube("bobblocks_"..block..".png"),
  65. paramtype = "light",
  66. sunlight_propagates = true,
  67. is_ground_content = true,
  68. sounds = default.node_sound_glass_defaults(),
  69. light_source = LIGHT_MAX-0,
  70. groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
  71. })
  72. minetest.register_node("gold_and_gem:"..block.."_off", {
  73. description = bobname,
  74. tile_images = {"bobblocks_"..block.."_off.png"},
  75. is_ground_content = true,
  76. alpha = WATER_ALPHA,
  77. groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
  78. drop = "gold_and_gem:"..block,
  79. })
  80. end
  81. end
  82. for i in ipairs(bobbs) do
  83. local pole = bobbs[i][1]
  84. local bobname = bobbs[i][2]
  85. if string.find(pole, "pole") then
  86. blockname = ("bobblocks_"..pole.."block")
  87. if string.find(blockname, "pole") then
  88. blockname = blockname:gsub("pole", "")
  89. end
  90. minetest.register_node("gold_and_gem:"..pole, {
  91. description = bobname,
  92. drawtype = "fencelike",
  93. tile_images = {""..blockname..".png"},
  94. inventory_image = ("bobblocks_inv"..pole..".png"),
  95. paramtype = "light",
  96. sunlight_propagates = true,
  97. is_ground_content = true,
  98. sounds = default.node_sound_glass_defaults(),
  99. light_source = LIGHT_MAX-0,
  100. groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
  101. })
  102. minetest.register_node("gold_and_gem:"..pole.."_off", {
  103. description = bobname,
  104. drawtype = "fencelike",
  105. tile_images = {""..blockname.."_off.png"},
  106. inventory_image = ("bobblocks_inv"..pole..".png"),
  107. paramtype = "light",
  108. sunlight_propagates = true,
  109. is_ground_content = true,
  110. sounds = default.node_sound_glass_defaults(),
  111. light_source = LIGHT_MAX-10,
  112. groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
  113. drop = "gold_and_gem:"..pole,
  114. })
  115. end
  116. end
  117. --new recipes:
  118. -- pink: ...a/pink wool
  119. --lime: uranium ingot /green wool (dark green)
  120. --cyan: ...talinite ingot /cyan wool
  121. --diamonds to chromium
  122. for i in ipairs(orig_bobbs) do
  123. local bob = orig_bobbs[i]
  124. minetest.register_alias("bobblocks:"..bob.."_off", "gold_and_gem:"..bob.."_off")
  125. minetest.register_alias("bobblocks:"..bob, "gold_and_gem:"..bob)
  126. end