walls_madison.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. local colbox_type1 = { --top blocks
  2. type = 'fixed',
  3. fixed = {-.5, -.5, -.2, .5, .5, .5}
  4. }
  5. local colbox_type2 = { --bottom blocks
  6. type = 'fixed',
  7. fixed = {-.5, -.5, -.2, .5, .5, .5}
  8. }
  9. local colbox_type3 = { --top inside corner
  10. type = 'fixed',
  11. fixed = {{-.2, -.5, -.5, .5, .5, .5},
  12. {-.5, -.5, -.2, .5, .5, .5}}
  13. }
  14. local colbox_type4 = { --bottom inside corner
  15. type = 'fixed',
  16. fixed = {{-.2, -.5, -.5, .5, .5, .5},
  17. {-.5, -.5, -.2, .5, .5, .5}}
  18. }
  19. local colbox_type5 = { --top outside corner
  20. type = 'fixed',
  21. fixed = {-.2, -.5, -.2, .5, .5, .5}
  22. }
  23. local colbox_type6 = { --bottom outside corner
  24. type = 'fixed',
  25. fixed = {-.2, -.5, -.2, .5, .5, .5}
  26. }
  27. local block_type1 = { -- desc2, typ, obj, colbox, drops, grup
  28. {'Madison Middle', 'middle', 'blockm_m_t', colbox_type1, 'middle', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  29. {'Hax0r', 'bmiddle', 'blockm_m_b', colbox_type2, 'middle', {not_in_creative_inventory=1}},
  30. {'Madison Inside Corner', 'icorner', 'blockm_ic_t', colbox_type3, 'icorner', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  31. {'Hax0r', 'bicorner', 'blockm_ic_b', colbox_type4, 'icorner', {not_in_creative_inventory=1}},
  32. {'Madison Outside Corner', 'ocorner', 'blockm_oc_t', colbox_type5, 'ocorner', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  33. {'Hax0r', 'bocorner', 'blockm_oc_b', colbox_type6, 'ocorner', {not_in_creative_inventory=1}},
  34. }
  35. for i in ipairs (block_type1) do
  36. local desc2 = block_type1[i][1]
  37. local typ = block_type1[i][2]
  38. local obj = block_type1[i][3]
  39. local colbox = block_type1[i][4]
  40. local drops = block_type1[i][5]
  41. local grup = block_type1[i][6]
  42. local color_tab = {
  43. {'black', 'Black', '^[multiply:#2c2c2c'},
  44. {'blue', 'Blue', '^[multiply:#0041f4'},
  45. {'brown', 'Brown', '^[multiply:#6c3800'},
  46. {'cyan', 'Cyan', '^[multiply:cyan'},
  47. {'dark_green', 'Dark Green', '^[multiply:#2b7b00'},
  48. {'dark_grey', 'Dark Grey', '^[multiply:#464646'},
  49. {'green', 'Green', '^[multiply:#67eb1c'},
  50. {'grey', 'Grey', '^[multiply:#818181'},
  51. {'magenta', 'Magenta', '^[multiply:#d80481'},
  52. {'orange', 'Orange', '^[multiply:#e0601a'},
  53. {'pink', 'Pink', '^[multiply:#ffa5a5'},
  54. {'red', 'Red', '^[multiply:#c91818'},
  55. {'violet', 'Violet', '^[multiply:#480680'},
  56. {'white', 'White', '^[multiply:white'},
  57. {'yellow', 'Yellow', '^[multiply:#fcf611'},
  58. {'cement', 'Concrete', ''},
  59. }
  60. for i in ipairs (color_tab) do
  61. local col = color_tab[i][1]
  62. local coldesc = color_tab[i][2]
  63. local alpha = color_tab[i][3]
  64. minetest.register_node('mylandscaping:mwall_'..typ..'_'..col, {
  65. _doc_items_create_entry = false,
  66. description = desc2..' '..coldesc,
  67. drawtype = 'mesh',
  68. mesh = 'mylandscaping_'..obj..'.obj',
  69. tiles = {{name='mylandscaping_madison_wood.png'}, {name='mylandscaping_madison_stone.png'..alpha}},
  70. groups = grup,
  71. paramtype = 'light',
  72. paramtype2 = 'facedir',
  73. drop = 'mylandscaping:mwall_'..drops..'_'..col,
  74. selection_box = colbox,
  75. collision_box = colbox,
  76. sounds = default.node_sound_stone_defaults(),
  77. after_place_node = function(pos, placer, itemstack, pointed_thing)
  78. local nodeu = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
  79. local nodea = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
  80. if nodeu.name == 'mylandscaping:mwall_'..typ..'_'..col then
  81. minetest.swap_node(pos,{name='mylandscaping:mwall_'..typ..'_'..col,param2=nodeu.param2})
  82. minetest.swap_node({x=pos.x,y=pos.y-1,z=pos.z},{name='mylandscaping:mwall_b'..typ..'_'..col,param2=nodeu.param2})
  83. end
  84. if nodea.name == 'mylandscaping:mwall_'..typ..'_'..col then
  85. minetest.swap_node(pos,{name='mylandscaping:mwall_b'..typ..'_'..col,param2=nodea.param2})
  86. end
  87. end,
  88. after_destruct = function(pos, oldnode)
  89. local nodeu = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
  90. if nodeu.name == 'mylandscaping:mwall_b'..typ..'_'..col then
  91. minetest.swap_node({x=pos.x,y=pos.y-1,z=pos.z},{name='mylandscaping:mwall_'..typ..'_'..col,param2=nodeu.param2})
  92. end
  93. end,
  94. })
  95. end
  96. end