walls_freeport.lua 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. local colbox_type1 = { --top blocks
  2. type = 'fixed',
  3. fixed = {{-.49, -.5, 0.05, .5, .5, .52}}
  4. }
  5. local colbox_type2 = { --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 = { --corner
  14. type = 'fixed',
  15. fixed = {{-.5, -.5, 0, .5, .5, .5},
  16. {0, -.5, -.5, .5, .5, .5}}
  17. }
  18. local colbox_type5 = { --corner
  19. type = 'fixed',
  20. fixed = {{-.5, -.5, -.5, .5, .5, .5},}
  21. }
  22. local colbox_type6 = { --corner
  23. type = 'fixed',
  24. fixed = {{-.5, -.5, -.3, .5, .5, .5},}
  25. }
  26. local block_type1 = { -- desc2, typ, obj, colbox, drops, grup
  27. {'Freeport Left', 'left', 'blockf_l_t', colbox_type1, 'left', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  28. {'Freeport Middle', 'middle', 'blockf_m_t', colbox_type1, 'middle', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  29. {'Freeport Right', 'right', 'blockf_r_t', colbox_type1, 'right', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  30. {'Freeport Inside Corner', 'corner', 'blockf_c_t', colbox_type4, 'corner', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  31. {'Hax0r', 'bleft', 'blockf_l_b', colbox_type3, 'left', {not_in_creative_inventory=1}},
  32. {'Hax0r', 'bmiddle', 'blockf_m_b', colbox_type3, 'middle', {not_in_creative_inventory=1}},
  33. {'Hax0r', 'bright', 'blockf_r_b', colbox_type3, 'right', {not_in_creative_inventory=1}},
  34. {'Hax0r', 'bcorner', 'blockf_c_b', colbox_type4, 'corner', {not_in_creative_inventory=1}},
  35. {'Freeport Column (IC)', 'column_ic_t', 'columnf_ic_t', colbox_type5, 'column_ic_t', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  36. {'Freeport Column (OC)', 'column_oc_t', 'columnf_oc_t', colbox_type2, 'column_oc_t', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  37. {'Freeport Column (M)', 'column_m_t', 'columnf_m_t', colbox_type6, 'column_m_t', {ml=1,cracky=2,not_in_creative_inventory=ml_visible}},
  38. {'Hax0r', 'bcolumn_ic_t', 'columnf_ic_b', colbox_type5, 'column_ic_b', {not_in_creative_inventory=1}},
  39. {'Hax0r', 'bcolumn_oc_t', 'columnf_oc_b', colbox_type2, 'column_oc_b', {not_in_creative_inventory=1}},
  40. {'Hax0r', 'bcolumn_m_t', 'columnf_m_b', colbox_type6, 'column_m_b', {not_in_creative_inventory=1}},
  41. }
  42. for i in ipairs (block_type1) do
  43. local desc2 = block_type1[i][1]
  44. local typ = block_type1[i][2]
  45. local obj = block_type1[i][3]
  46. local colbox = block_type1[i][4]
  47. local drops = block_type1[i][5]
  48. local grup = block_type1[i][6]
  49. local color_tab = {
  50. {'black', 'Black', '^[multiply:#2c2c2c'},
  51. {'blue', 'Blue', '^[multiply:#0041f4'},
  52. {'brown', 'Brown', '^[multiply:#6c3800'},
  53. {'cyan', 'Cyan', '^[multiply:cyan'},
  54. {'dark_green', 'Dark Green', '^[multiply:#2b7b00'},
  55. {'dark_grey', 'Dark Grey', '^[multiply:#464646'},
  56. {'green', 'Green', '^[multiply:#67eb1c'},
  57. {'grey', 'Grey', '^[multiply:#818181'},
  58. {'magenta', 'Magenta', '^[multiply:#d80481'},
  59. {'orange', 'Orange', '^[multiply:#e0601a'},
  60. {'pink', 'Pink', '^[multiply:#ffa5a5'},
  61. {'red', 'Red', '^[multiply:#c91818'},
  62. {'violet', 'Violet', '^[multiply:#480680'},
  63. {'white', 'White', '^[multiply:white'},
  64. {'yellow', 'Yellow', '^[multiply:#fcf611'},
  65. {'cement', 'Concrete', ''},
  66. }
  67. for i in ipairs (color_tab) do
  68. local col = color_tab[i][1]
  69. local coldesc = color_tab[i][2]
  70. local alpha = color_tab[i][3]
  71. minetest.register_node('mylandscaping:fwall_'..typ..'_'..col, {
  72. _doc_items_create_entry = false,
  73. description = desc2..' '..coldesc,
  74. drawtype = 'mesh',
  75. mesh = 'mylandscaping_'..obj..'.obj',
  76. tiles = {{name='mylandscaping_block_smooth.png'..alpha}, {name='mylandscaping_block_split.png'..alpha}},
  77. groups = grup,
  78. paramtype = 'light',
  79. paramtype2 = 'facedir',
  80. drop = 'mylandscaping:fwall_'..drops..'_'..col,
  81. selection_box = colbox,
  82. collision_box = colbox,
  83. sounds = default.node_sound_stone_defaults(),
  84. after_place_node = function(pos, placer, itemstack)
  85. local nodeu = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
  86. local nodea = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
  87. if nodeu.name == 'mylandscaping:fwall_'..typ..'_'..col then
  88. minetest.swap_node(pos,{name='mylandscaping:fwall_'..typ..'_'..col,param2=nodeu.param2})
  89. minetest.swap_node({x=pos.x,y=pos.y-1,z=pos.z},{name='mylandscaping:fwall_b'..typ..'_'..col,param2=nodeu.param2})
  90. end
  91. if nodea.name == 'mylandscaping:fwall_'..typ..'_'..col then
  92. minetest.swap_node(pos,{name='mylandscaping:fwall_b'..typ..'_'..col,param2=nodea.param2})
  93. end
  94. end,
  95. after_destruct = function(pos, oldnode)
  96. local nodeu = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
  97. if nodeu.name == 'mylandscaping:fwall_b'..typ..'_'..col then
  98. minetest.swap_node({x=pos.x,y=pos.y-1,z=pos.z},{name='mylandscaping:fwall_'..typ..'_'..col,param2=nodeu.param2})
  99. end
  100. end,
  101. })
  102. end
  103. end