nodes.lua 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. minetest.register_node('hall:stanchion_post', {
  2. description = 'Stanchion post',
  3. drawtype = 'mesh',
  4. mesh = 'hall_stanchion_post.obj',
  5. tiles = {'default_aspen_wood.png'},
  6. sounds = default.node_sound_wood_defaults(),
  7. paramtype2 = 'facedir',
  8. paramtype = 'light',
  9. selection_box = {
  10. type = 'fixed',
  11. fixed = {-.2, -.5, -.2, .2, .5, .2},
  12. },
  13. collision_box = {
  14. type = 'fixed',
  15. fixed = {-.2, -.5, -.2, .2, .5, .2},
  16. },
  17. groups = {oddly_breakable_by_hand = 2, choppy=3},
  18. })
  19. minetest.register_node('hall:stanchion_post_sign', {
  20. description = 'Stanchion post',
  21. drawtype = 'mesh',
  22. mesh = 'hall_stanchion_post_sign.obj',
  23. tiles = {'default_aspen_wood.png', 'hall_plaque_texture.png'},
  24. sounds = default.node_sound_wood_defaults(),
  25. paramtype2 = 'facedir',
  26. paramtype = 'light',
  27. selection_box = {
  28. type = 'fixed',
  29. fixed = {-.2, -.5, -.2, .2, .5, .2},
  30. },
  31. collision_box = {
  32. type = 'fixed',
  33. fixed = {-.2, -.5, -.2, .2, .5, .2},
  34. },
  35. groups = {oddly_breakable_by_hand = 2, choppy=3},
  36. after_place_node = function(pos, placer)
  37. local meta = minetest.get_meta(pos)
  38. meta:set_string('owner', placer:get_player_name())
  39. meta:set_string('infotext', 'Empty Sign')
  40. meta:set_string('title', '')
  41. meta:set_string('bottom', '')
  42. meta:set_string('left', '')
  43. meta:set_string('right', '')
  44. end,
  45. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
  46. local name = clicker:get_player_name()
  47. local meta = minetest.get_meta(pos)
  48. local owner = meta:get_string('owner')
  49. local title = meta:get_string('title')
  50. local bottom = meta:get_string('bottom')
  51. local left = meta:get_string('left')
  52. local right = meta:get_string('right')
  53. if owner == name then
  54. meta:set_string('formspec', hall.edit_sign(title, bottom, left, right))
  55. else
  56. meta:set_string('formspec', hall.view_sign(title, bottom, left, right))
  57. end
  58. end,
  59. on_receive_fields = function(pos, formname, fields, sender)
  60. local meta = minetest.get_meta(pos)
  61. if fields ['save'] then
  62. local player_name = sender:get_player_name()
  63. meta:set_string('infotext', fields.title)
  64. meta:set_string('title', fields.title)
  65. meta:set_string('bottom', fields.bottom)
  66. meta:set_string('left', fields.left)
  67. meta:set_string('right', fields.right)
  68. minetest.log("action", (player_name or "").." wrote \""..fields.title.."\" to stanchion at "..minetest.pos_to_string(pos))
  69. end
  70. end,
  71. })
  72. minetest.register_node('hall:stanchion_rope', {
  73. description = 'Stanchion rope',
  74. drawtype = 'mesh',
  75. mesh = 'hall_stanchion_rope.obj',
  76. tiles = {'wool.png^[multiply:#1a1a1a'},
  77. paramtype2 = 'facedir',
  78. paramtype = 'light',
  79. selection_box = {
  80. type = 'fixed',
  81. fixed = {-.6, -.2, -.2, .6, .4, .2},
  82. },
  83. collision_box = {
  84. type = 'fixed',
  85. fixed = {-.6, -.2, -.2, .6, .4, .2},
  86. },
  87. groups = {oddly_breakable_by_hand = 2, snappy=3},
  88. })
  89. minetest.register_node('hall:stanchion_rope_sign', {
  90. description = 'Stanchion rope',
  91. drawtype = 'mesh',
  92. mesh = 'hall_stanchion_rope_sign.obj',
  93. tiles = {'wool.png^[multiply:#1a1a1a','hall_plaque_texture.png'},
  94. paramtype2 = 'facedir',
  95. paramtype = 'light',
  96. selection_box = {
  97. type = 'fixed',
  98. fixed = {-.6, -.2, -.2, .6, .4, .2},
  99. },
  100. collision_box = {
  101. type = 'fixed',
  102. fixed = {-.6, -.2, -.2, .6, .4, .2},
  103. },
  104. groups = {oddly_breakable_by_hand = 2, snappy=3},
  105. after_place_node = function(pos, placer)
  106. local meta = minetest.get_meta(pos)
  107. meta:set_string('owner', placer:get_player_name())
  108. meta:set_string('infotext', 'Empty Sign')
  109. meta:set_string('title', '')
  110. meta:set_string('bottom', '')
  111. meta:set_string('left', '')
  112. meta:set_string('right', '')
  113. end,
  114. on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
  115. local name = clicker:get_player_name()
  116. local meta = minetest.get_meta(pos)
  117. local owner = meta:get_string('owner')
  118. local title = meta:get_string('title')
  119. local bottom = meta:get_string('bottom')
  120. local left = meta:get_string('left')
  121. local right = meta:get_string('right')
  122. if owner == name then
  123. meta:set_string('formspec', hall.edit_sign(title, bottom, left, right))
  124. else
  125. meta:set_string('formspec', hall.view_sign(title, bottom, left, right))
  126. end
  127. end,
  128. on_receive_fields = function(pos, formname, fields, sender)
  129. local meta = minetest.get_meta(pos)
  130. if fields ['save'] then
  131. local player_name = sender:get_player_name()
  132. meta:set_string('infotext', fields.title)
  133. meta:set_string('title', fields.title)
  134. meta:set_string('bottom', fields.bottom)
  135. meta:set_string('left', fields.left)
  136. meta:set_string('right', fields.right)
  137. minetest.log("action", (player_name or "").." wrote \""..fields.title.."\" to stanchion at "..minetest.pos_to_string(pos))
  138. end
  139. end,
  140. })