walls_adaridge.lua 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. local colbox_type1 = { --top blocks
  2. type = 'fixed',
  3. fixed = {{-.49, -.5, 0.05, .5, .5, .52}}
  4. }
  5. local colbox_type2 = { --outside corner columns
  6. type = 'fixed',
  7. fixed = {{-.2, -.5, -.2, .5, .5, .5}}
  8. }
  9. local colbox_type3 = { --bottom blocks
  10. type = 'fixed',
  11. fixed = {{-.5, -.5, -.16, .5, .5, .25}}
  12. }
  13. local colbox_type4 = { --inside corner
  14. type = 'fixed',
  15. fixed = {{-.5, -.5, 0, .5, .5, .5},
  16. {0, -.5, -.5, .5, .5, .5}}
  17. }
  18. local colbox_type5 = { --inside corner column
  19. type = 'fixed',
  20. fixed = {{-.5, -.5, -.5, .5, .5, .5},}
  21. }
  22. local colbox_type6 = { --middle column
  23. type = 'fixed',
  24. fixed = {{-.5, -.5, -.3, .5, .5, .5},}
  25. }
  26. local colbox_type7 = { --outside corner
  27. type = 'fixed',
  28. fixed = {{-.5, -.5, -.3, .5, .5, .5},}
  29. }
  30. local block_type1 = { -- desc2, typ, obj, colbox, drops, grup
  31. {'Adaridge Left', 'left', 'blocka_l_t', colbox_type1, 'left', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  32. {'Adaridge Middle', 'middle', 'blocka_m_t', colbox_type1, 'middle', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  33. {'Adaridge Right', 'right', 'blocka_r_t', colbox_type1, 'right', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  34. {'Adaridge Inside Corner', 'icorner', 'blocka_ic_t', colbox_type4, 'icorner', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  35. {'Adaridge Outside Corner', 'ocorner', 'blocka_oc_t', colbox_type2, 'ocorner', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  36. {'Hax0r', 'bleft', 'blocka_l_b', colbox_type3, 'left', {not_in_creative_inventory=1}},
  37. {'Hax0r', 'bmiddle', 'blocka_m_b', colbox_type3, 'middle', {not_in_creative_inventory=1}},
  38. {'Hax0r', 'bright', 'blocka_r_b', colbox_type3, 'right', {not_in_creative_inventory=1}},
  39. {'Hax0r', 'bicorner', 'blocka_ic_b', colbox_type4, 'icorner', {not_in_creative_inventory=1}},
  40. {'Hax0r', 'bocorner', 'blocka_oc_b', colbox_type2, 'ocorner', {not_in_creative_inventory=1}},
  41. {'Adaridge Column (IC)', 'column_ic_t', 'columna_ic_t', colbox_type5, 'column_ic_t', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  42. {'Adaridge Column (OC)', 'column_oc_t', 'columna_oc_t', colbox_type2, 'column_oc_t', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  43. {'Adaridge Column (M)', 'column_m_t', 'columna_m_t', colbox_type6, 'column_m_t', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  44. {'Hax0r', 'bcolumn_ic_t', 'columna_ic_b', colbox_type5, 'column_ic_b', {not_in_creative_inventory=1}},
  45. {'Hax0r', 'bcolumn_oc_t', 'columna_oc_b', colbox_type2, 'column_oc_b', {not_in_creative_inventory=1}},
  46. {'Hax0r', 'bcolumn_m_t', 'columna_m_b', colbox_type6, 'column_m_b', {not_in_creative_inventory=1}},
  47. }
  48. for i in ipairs (block_type1) do
  49. local desc2 = block_type1[i][1]
  50. local typ = block_type1[i][2]
  51. local obj = block_type1[i][3]
  52. local colbox = block_type1[i][4]
  53. local drops = block_type1[i][5]
  54. local grup = block_type1[i][6]
  55. local color_tab = {
  56. {'black', 'Black', '^[multiply:#2c2c2c'},
  57. {'blue', 'Blue', '^[multiply:#0041f4'},
  58. {'brown', 'Brown', '^[multiply:#6c3800'},
  59. {'cyan', 'Cyan', '^[multiply:cyan'},
  60. {'dark_green', 'Dark Green', '^[multiply:#2b7b00'},
  61. {'dark_grey', 'Dark Grey', '^[multiply:#464646'},
  62. {'green', 'Green', '^[multiply:#67eb1c'},
  63. {'grey', 'Grey', '^[multiply:#818181'},
  64. {'magenta', 'Magenta', '^[multiply:#d80481'},
  65. {'orange', 'Orange', '^[multiply:#e0601a'},
  66. {'pink', 'Pink', '^[multiply:#ffa5a5'},
  67. {'red', 'Red', '^[multiply:#c91818'},
  68. {'violet', 'Violet', '^[multiply:#480680'},
  69. {'white', 'White', '^[multiply:white'},
  70. {'yellow', 'Yellow', '^[multiply:#fcf611'},
  71. {'cement', 'Concrete', ''},
  72. }
  73. for i in ipairs (color_tab) do
  74. local col = color_tab[i][1]
  75. local coldesc = color_tab[i][2]
  76. local alpha = color_tab[i][3]
  77. minetest.register_node('mylandscaping:awall_'..typ..'_'..col, {
  78. description = desc2..' '..coldesc,
  79. drawtype = 'mesh',
  80. mesh = 'mylandscaping_'..obj..'.obj',
  81. tiles = {{name='mylandscaping_adaridge_tex.png'..alpha}},
  82. groups = grup,
  83. paramtype = 'light',
  84. paramtype2 = 'facedir',
  85. drop = 'mylandscaping:awall_'..drops..'_'..col,
  86. selection_box = colbox,
  87. collision_box = colbox,
  88. sounds = default.node_sound_stone_defaults(),
  89. after_place_node = function(pos, placer, itemstack, pointed_thing)
  90. local nodeu = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
  91. local nodea = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
  92. local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
  93. if nodeu.name == 'mylandscaping:awall_'..typ..'_'..col then
  94. minetest.swap_node(pos,{name='mylandscaping:awall_'..typ..'_'..col,param2=nodeu.param2})
  95. minetest.swap_node({x=pos.x,y=pos.y-1,z=pos.z},{name='mylandscaping:awall_b'..typ..'_'..col,param2=nodeu.param2})
  96. end
  97. if nodea.name == 'mylandscaping:awall_'..typ..'_'..col then
  98. minetest.swap_node(pos,{name='mylandscaping:awall_b'..typ..'_'..col,param2=nodea.param2})
  99. end
  100. end,
  101. after_destruct = function(pos, oldnode)
  102. local nodeu = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
  103. if nodeu.name == 'mylandscaping:awall_b'..typ..'_'..col then
  104. minetest.swap_node({x=pos.x,y=pos.y-1,z=pos.z},{name='mylandscaping:awall_'..typ..'_'..col,param2=nodeu.param2})
  105. end
  106. end,
  107. })
  108. end
  109. end