gravestones.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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, tomb=1}
  20. if minetest.settings:get_bool('tombs.creative') then
  21. group = {oddly_breakable_by_hand=2, cracky=3, tomb=1}
  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. _doc_items_create_entry = false,
  30. description = desc..' Headstone ('..shape..')',
  31. drawtype = 'mesh',
  32. mesh = 'tombs'..mesh..'_0.obj',
  33. tiles = {textures..'.png'},
  34. use_texture_alpha = 'opaque',
  35. paramtype = 'light',
  36. paramtype2 = 'facedir',
  37. light_source = light,
  38. selection_box = centered_col,
  39. collision_box = centered_col,
  40. groups = group,
  41. on_construct = function(pos)
  42. local meta = minetest.get_meta(pos)
  43. meta:set_string('formspec', 'field[text;;${text}]')
  44. meta:set_string('infotext', '')
  45. end,
  46. after_place_node = function(pos, placer)
  47. local meta = minetest.get_meta(pos)
  48. meta:set_string('owner',placer:get_player_name())
  49. end,
  50. on_receive_fields = function(pos, formname, fields, sender)
  51. local meta = minetest.get_meta(pos)
  52. if sender:get_player_name() == meta:get_string('owner') then
  53. if not fields.text then return end
  54. meta:set_string('text', fields.text)
  55. meta:set_string('infotext', fields.text)
  56. end
  57. end,
  58. })
  59. minetest.register_node('tombs:'..string.lower(name)..mesh..'_1', {
  60. _doc_items_create_entry = false,
  61. description = 'Offset '..desc..' Headstone ('..shape..')',
  62. drawtype = 'mesh',
  63. mesh = 'tombs'..mesh..'_1.obj',
  64. tiles = {textures..'.png'},
  65. use_texture_alpha = 'opaque',
  66. paramtype = 'light',
  67. paramtype2 = 'facedir',
  68. light_source = light,
  69. selection_box = offset_col,
  70. collision_box = offset_col,
  71. groups = group,
  72. on_construct = function(pos)
  73. local meta = minetest.get_meta(pos)
  74. meta:set_string('formspec', 'field[text;;${text}]')
  75. meta:set_string('infotext', '')
  76. end,
  77. after_place_node = function(pos, placer)
  78. local meta = minetest.get_meta(pos)
  79. meta:set_string('owner',placer:get_player_name())
  80. end,
  81. on_receive_fields = function(pos, formname, fields, sender)
  82. local meta = minetest.get_meta(pos)
  83. if sender:get_player_name() == meta:get_string('owner') then
  84. if not fields.text then return end
  85. meta:set_string('text', fields.text)
  86. meta:set_string('infotext', fields.text)
  87. end
  88. end,
  89. })
  90. end
  91. tombs.nodes[recipe] = true
  92. tombs.recipes[recipe] = string.lower(name)
  93. end
  94. function tombs.crafting(input, var)
  95. local name = tombs.recipes[input]
  96. local output =
  97. {'tombs:'..name..'_0_'..var, 'tombs:'..name..'_1_'..var, 'tombs:'..name..'_2_'..var,
  98. 'tombs:'..name..'_3_'..var, 'tombs:'..name..'_4_'..var, 'tombs:'..name..'_5_'..var,
  99. 'tombs:'..name..'_6_'..var, 'tombs:'..name..'_7_'..var, 'tombs:'..name..'_8_'..var,
  100. 'tombs:'..name..'_9_'..var, 'tombs:'..name..'_10_'..var, 'tombs:'..name..'_11_'..var,
  101. 'tombs:'..name..'_12_'..var, 'tombs:'..name..'_13_'..var, 'tombs:'..name..'_14_'..var,
  102. }
  103. return output
  104. end