gravestones.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. function tombs.register_stones(recipe, name, desc, textures, light)
  2. local shapes = { --mesh identifier, shape, col
  3. {'_0', 'Rectangle', colbox_0_0, colbox_0_1},
  4. {'_1', 'Cross', colbox_1_0, colbox_1_1},
  5. {'_2', 'Pointed', colbox_0_0, colbox_0_1},
  6. {'_3', 'Short Slanted', colbox_3_0, colbox_3_1},
  7. {'_4', 'Short Flat', colbox_4_0, colbox_4_1},
  8. {'_5', 'Fancy Cross', colbox_5_0, colbox_5_1},
  9. {'_6', 'Staggered', colbox_6_0, colbox_6_1},
  10. {'_7', 'Celtic Cross', colbox_7_0, colbox_7_1},
  11. {'_8', 'Obelisk', colbox_8_0, colbox_8_1},
  12. {'_9', 'Stacked', colbox_9_0, colbox_9_0},
  13. {'_10', 'Rounded', colbox_0_0, colbox_0_1},
  14. {'_11', 'Sam', colbox_11_0, colbox_11_1},
  15. {'_12', '5 Pointed Star', colbox_12_0, colbox_12_1},
  16. {'_13', '6 Pointed Star', colbox_12_0, colbox_12_1},
  17. {'_14', 'Octothorp', colbox_14_0, colbox_14_1},
  18. }
  19. local group = {oddly_breakable_by_hand=2, not_in_creative_inventory=1}
  20. if minetest.settings:get_bool('tombs.creative') then
  21. group = {oddly_breakable_by_hand=2, cracky=3}
  22. end
  23. for i in ipairs (shapes) do
  24. local mesh = shapes[i][1]
  25. local shape = shapes[i][2]
  26. local centered_col = shapes[i][3]
  27. local offset_col = shapes[i][4]
  28. minetest.register_node('tombs:'..string.lower(name)..mesh..'_0', {
  29. description = desc..' Headstone ('..shape..')',
  30. drawtype = 'mesh',
  31. mesh = 'tombs'..mesh..'_0.obj',
  32. tiles = {textures..'.png'},
  33. paramtype = 'light',
  34. paramtype2 = 'facedir',
  35. light_source = light,
  36. selection_box = centered_col,
  37. collision_box = centered_col,
  38. groups = group,
  39. on_construct = function(pos)
  40. local meta = minetest.get_meta(pos)
  41. meta:set_string('formspec', 'field[text;;${text}]')
  42. meta:set_string('infotext', '')
  43. end,
  44. after_place_node = function(pos, placer)
  45. local meta = minetest.get_meta(pos)
  46. meta:set_string('owner',placer:get_player_name())
  47. end,
  48. on_receive_fields = function(pos, formname, fields, sender)
  49. local meta = minetest.get_meta(pos)
  50. if sender:get_player_name() == meta:get_string('owner') then
  51. if not fields.text then return end
  52. meta:set_string('text', fields.text)
  53. meta:set_string('infotext', fields.text)
  54. end
  55. end,
  56. })
  57. minetest.register_node('tombs:'..string.lower(name)..mesh..'_1', {
  58. description = 'Offset '..desc..' Headstone ('..shape..')',
  59. drawtype = 'mesh',
  60. mesh = 'tombs'..mesh..'_1.obj',
  61. tiles = {textures..'.png'},
  62. paramtype = 'light',
  63. paramtype2 = 'facedir',
  64. light_source = light,
  65. selection_box = offset_col,
  66. collision_box = offset_col,
  67. groups = group,
  68. on_construct = function(pos)
  69. local meta = minetest.get_meta(pos)
  70. meta:set_string('formspec', 'field[text;;${text}]')
  71. meta:set_string('infotext', '')
  72. end,
  73. after_place_node = function(pos, placer)
  74. local meta = minetest.get_meta(pos)
  75. meta:set_string('owner',placer:get_player_name())
  76. end,
  77. on_receive_fields = function(pos, formname, fields, sender)
  78. local meta = minetest.get_meta(pos)
  79. if sender:get_player_name() == meta:get_string('owner') then
  80. if not fields.text then return end
  81. meta:set_string('text', fields.text)
  82. meta:set_string('infotext', fields.text)
  83. end
  84. end,
  85. })
  86. end
  87. tombs.nodes[recipe] = true
  88. tombs.recipes[recipe] = string.lower(name)
  89. end
  90. function tombs.crafting(input, var)
  91. local name = tombs.recipes[input]
  92. local output =
  93. {'tombs:'..name..'_0_'..var, 'tombs:'..name..'_1_'..var, 'tombs:'..name..'_2_'..var,
  94. 'tombs:'..name..'_3_'..var, 'tombs:'..name..'_4_'..var, 'tombs:'..name..'_5_'..var,
  95. 'tombs:'..name..'_6_'..var, 'tombs:'..name..'_7_'..var, 'tombs:'..name..'_8_'..var,
  96. 'tombs:'..name..'_9_'..var, 'tombs:'..name..'_10_'..var, 'tombs:'..name..'_11_'..var,
  97. 'tombs:'..name..'_12_'..var, 'tombs:'..name..'_13_'..var, 'tombs:'..name..'_14_'..var,
  98. }
  99. return output
  100. end