floors.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. local colbox_floor = {
  2. type = 'fixed',
  3. fixed = {
  4. {-.5, .3, -.5, .5, .5, .5},
  5. }
  6. }
  7. local colbox_floor_edge = {
  8. type = 'fixed',
  9. fixed = {
  10. {-.5, .3, -.5, .5, .5, .5},
  11. }
  12. }
  13. local colbox_floor_square = {
  14. type = 'fixed',
  15. fixed = {
  16. {-.5, .4, -.5, .5, .5, .5},
  17. }
  18. }
  19. local colbox_floor_angle = {
  20. type = 'fixed',
  21. fixed = {
  22. {.25, .4, 0, .5, .5, .25},
  23. {0, .4, -.5, .5, .5, 0},
  24. {-.25, .4, -.25, 0, .5, -.5}
  25. }
  26. }
  27. local colbox_ramp_1 = {
  28. type = 'fixed',
  29. fixed = {
  30. {-.5, -.5, 0, .5, 0, .5},
  31. {-.5, -.5, -.5, .5, -.25, 0},
  32. }
  33. }
  34. local colbox_stair = { --Stairs nodebox
  35. type = 'fixed',
  36. fixed = {
  37. {-.5, -.5, -.5, .5, 0, .5},
  38. {-.5, 0, 0, .5, .5, .5},
  39. }}
  40. minetest.register_node('ship:floor', {
  41. description = 'Floor',
  42. drawtype = 'mesh',
  43. mesh = 'ship_floor.obj',
  44. paramtype = 'light',
  45. paramtype2 = 'facedir',
  46. selection_box = colbox_floor,
  47. collision_box = colbox_floor,
  48. tiles = {'ship_floor_blank.png'},
  49. groups = {breakable=1}
  50. })
  51. minetest.register_node('ship:ramp1', {
  52. description = 'Ramp Bottom',
  53. drawtype = 'mesh',
  54. mesh = 'ship_ramp-1.obj',
  55. paramtype = 'light',
  56. paramtype2 = 'facedir',
  57. selection_box = colbox_ramp_1,
  58. collision_box = colbox_ramp_1,
  59. tiles = {'ship_floor_blank.png'},
  60. groups = {breakable=1}
  61. })
  62. minetest.register_node('ship:ramp2', {
  63. description = 'Ramp Top',
  64. drawtype = 'mesh',
  65. mesh = 'ship_ramp-2.obj',
  66. paramtype = 'light',
  67. paramtype2 = 'facedir',
  68. selection_box = colbox_stair,
  69. collision_box = colbox_stair,
  70. tiles = {'ship_floor_blank.png'},
  71. groups = {breakable=1}
  72. })
  73. minetest.register_node('ship:stairs', {
  74. description = 'Stairs',
  75. drawtype = 'mesh',
  76. mesh = 'ship_stairs.obj',
  77. paramtype = 'light',
  78. paramtype2 = 'facedir',
  79. selection_box = colbox_stair,
  80. collision_box = colbox_stair,
  81. tiles = {'ship_rail_blank.png', 'ship_floor_blank.png'},
  82. groups = {breakable=1}
  83. })
  84. for i in ipairs (ship_parts_colors) do
  85. local shipcol = ship_parts_colors[i][1]
  86. local shipval = ship_parts_colors[i][2]
  87. local shipdesc = ship_parts_colors[i][3]
  88. local ship_floor = { -- description, name, model, texture, colbox
  89. {shipcol..' Walkway Inside Corner', shipdesc..'eic', 'edge_incorner', '(ship_ship_floor_corner_inside.png^['..shipval..')', colbox_floor_edge},
  90. {shipcol..' Walkway Outside Corner', shipdesc..'eoc', 'edge_outcorner', '(ship_ship_floor_outcorn.png^['..shipval..')', colbox_floor_edge},
  91. {shipcol..' Walkway Edge', shipdesc..'es', 'edge_straight', '(ship_ship_floor.png^['..shipval..')', colbox_floor_edge},
  92. {shipcol..' Floor Angle', shipdesc..'fa', 'floor_angle', '(ship_ship_floor_angle.png^['..shipval..')', colbox_floor_angle},
  93. {shipcol..' Floor Square', shipdesc..'fs', 'floor_square', '(ship_ship_floor_double.png^['..shipval..')', colbox_floor_square},
  94. {shipcol..' Ramp Top Right', shipdesc..'r2r', 'ramp-2', '(ship_ship_floor.png^['..shipval..')^[transform2', colbox_stair},
  95. {shipcol..' Ramp Bottom Right', shipdesc..'r1r', 'ramp-1', '(ship_ship_floor.png^['..shipval..')^[transform2', colbox_ramp_1},
  96. {shipcol..' Ramp Top Left', shipdesc..'r2l', 'ramp-2', '(ship_ship_floor.png^['..shipval..')', colbox_stair},
  97. {shipcol..' Ramp Bottom Left', shipdesc..'r1l', 'ramp-1', '(ship_ship_floor.png^['..shipval..')', colbox_ramp_1}
  98. }
  99. for i in ipairs (ship_floor) do
  100. local desc = ship_floor[i][1]
  101. local name = ship_floor[i][2]
  102. local model = ship_floor[i][3]
  103. local tex = ship_floor[i][4]
  104. local colbox = ship_floor[i][5]
  105. minetest.register_node('ship:'..name, {
  106. description = desc,
  107. drawtype = 'mesh',
  108. mesh = 'ship_'..model..'.obj',
  109. paramtype = 'light',
  110. paramtype2 = 'facedir',
  111. light_source = 3,
  112. selection_box = colbox,
  113. collision_box = colbox,
  114. tiles = {'ship_floor_blank.png^'..tex, 'ship_floor_blank.png'},
  115. groups = {breakable=1},
  116. after_place_node = function(pos, placer, itemstack, pointed_thing)
  117. local something = pointed_thing.under
  118. local node = minetest.get_node(pointed_thing.under)
  119. if node.name == 'ship:'..name then
  120. minetest.set_node(pos, {name = 'ship:'..name, param2=node.param2})
  121. end
  122. end,
  123. })
  124. end
  125. end