traffic_signs.lua 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. local function on_construct(pos)
  2. local meta = minetest.get_meta(pos)
  3. meta:set_string('formspec', 'field[text;;${text}]')
  4. meta:set_string('infotext', '')
  5. end
  6. local function on_receive_fields(pos, formname, fields, sender)
  7. local meta = minetest.get_meta(pos)
  8. local name = sender:get_player_name()
  9. if not minetest.is_protected(pos, name) or minetest.check_player_privs(name, { server = true }) then
  10. if not fields.text then return end
  11. meta:set_string('text', fields.text)
  12. meta:set_string('infotext', fields.text)
  13. end
  14. end
  15. minetest.register_node('furniture:traffic_sign_address_1', {
  16. description = 'Street Sign (Single)',
  17. drawtype = 'mesh',
  18. mesh = 'furniture_street_sign_address_1.obj',
  19. tiles = {'furniture_traffic_sign_post.png', 'furniture_traffic_sign_streets.png'},
  20. paramtype = 'light',
  21. paramtype2 = 'facedir',
  22. selection_box = {
  23. type = 'fixed',
  24. fixed = {{-.0625, -1, -.0625, .0625, 1.5, .0625}, --post
  25. {-.5, 1.25, -.0625, .5, 1.4375, -.03125}}},
  26. collision_box = {
  27. type = 'fixed',
  28. fixed = {-.0625, -1, -.0625, .0625, 1.5, .0625}},
  29. groups = {breakable=1},
  30. on_construct = on_construct,
  31. on_receive_fields = on_receive_fields
  32. })
  33. minetest.register_node('furniture:traffic_sign_address_2', {
  34. description = 'Street Sign (Double)',
  35. drawtype = 'mesh',
  36. mesh = 'furniture_street_sign_address_2.obj',
  37. tiles = {'furniture_traffic_sign_post.png', 'furniture_traffic_sign_streets.png'},
  38. paramtype = 'light',
  39. paramtype2 = 'facedir',
  40. selection_box = {
  41. type = 'fixed',
  42. fixed = {{-.0625, -1, -.0625, .0625, 1.5, .0625},
  43. {-.5, 1.25, -.0625, .5, 1.4375, -.03125}}},
  44. collision_box = {
  45. type = 'fixed',
  46. fixed = {-.0625, -1, -.0625, .0625, 1.5, .0625}},
  47. groups = {breakable=1},
  48. on_construct = on_construct,
  49. after_place_node = function(pos, placer)
  50. local node = minetest.get_node(pos)
  51. local above_pos = {x=pos.x, y=pos.y+1, z=pos.z}
  52. minetest.set_node(above_pos, {name = 'furniture:traffic_sign_address_hidden', param2 = node.param2})
  53. end,
  54. on_receive_fields = on_receive_fields,
  55. on_destruct = function(pos)
  56. local above_pos = {x=pos.x, y=pos.y+1, z=pos.z}
  57. minetest.remove_node(above_pos)
  58. end,
  59. })
  60. minetest.register_node('furniture:traffic_sign_address_hidden', {
  61. drawtype = 'airlike',
  62. paramtype2 = 'facedir',
  63. selection_box = {
  64. type = 'fixed',
  65. fixed = {.0625, .0625, -.5, .03125, .25, .5}},
  66. drop = 'furniture:traffic_sign_address_2',
  67. groups = {breakable=1, not_in_creative_inventory=1},
  68. on_construct = on_construct,
  69. on_receive_fields = on_receive_fields,
  70. on_destruct = function(pos)
  71. local below_pos = {x=pos.x, y=pos.y-1, z=pos.z}
  72. minetest.remove_node(below_pos)
  73. end,
  74. })
  75. minetest.register_node('furniture:traffic_sign_stop', {
  76. description = 'Stop Sign',
  77. drawtype = 'mesh',
  78. mesh = 'furniture_traffic_sign_stop.obj',
  79. tiles = {'furniture_traffic_sign_post.png', 'furniture_traffic_sign_stop.png'},
  80. paramtype = 'light',
  81. paramtype2 = 'facedir',
  82. selection_box = {
  83. type = 'fixed',
  84. fixed = {{-.0625, -1, -.0625, .0625, 1.5, .0625},
  85. {-.5, .5, -.0625, .5, 1.5, -.03125}}},
  86. collision_box = {
  87. type = 'fixed',
  88. fixed = {-.0625, -1, -.0625, .0625, 1.5, .0625}},
  89. groups = {breakable=1},
  90. })
  91. minetest.register_node('furniture:traffic_sign_speed_55', {
  92. description = 'Speed Limit 55',
  93. drawtype = 'mesh',
  94. mesh = 'furniture_traffic_sign_speed.obj',
  95. tiles = {'furniture_traffic_sign_post.png', 'furniture_traffic_sign_speed_55.png'},
  96. paramtype = 'light',
  97. paramtype2 = 'facedir',
  98. selection_box = {
  99. type = 'fixed',
  100. fixed = {{-.0625, -1, -.0625, .0625, 1.5, .0625},
  101. {-.5, .5, -.0625, .5, 1.5, -.03125}}},
  102. collision_box = {
  103. type = 'fixed',
  104. fixed = {-.0625, -1, -.0625, .0625, 1.5, .0625}},
  105. groups = {breakable=1},
  106. })
  107. minetest.register_node('furniture:traffic_sign_no_parking', {
  108. description = 'No Parking',
  109. drawtype = 'mesh',
  110. mesh = 'furniture_traffic_sign_speed.obj',
  111. tiles = {'furniture_traffic_sign_post.png', 'furniture_traffic_sign_no_parking.png'},
  112. paramtype = 'light',
  113. paramtype2 = 'facedir',
  114. selection_box = {
  115. type = 'fixed',
  116. fixed = {{-.0625, -1, -.0625, .0625, 1.5, .0625},
  117. {-.5, .5, -.0625, .5, 1.5, -.03125}}},
  118. collision_box = {
  119. type = 'fixed',
  120. fixed = {-.0625, -1, -.0625, .0625, 1.5, .0625}},
  121. groups = {breakable=1},
  122. })
  123. minetest.register_node('furniture:traffic_sign_one_way', {
  124. description = 'One Way',
  125. drawtype = 'mesh',
  126. mesh = 'furniture_traffic_sign_speed.obj',
  127. tiles = {'furniture_traffic_sign_post.png', 'furniture_traffic_sign_one_way.png'},
  128. paramtype = 'light',
  129. paramtype2 = 'facedir',
  130. selection_box = {
  131. type = 'fixed',
  132. fixed = {{-.0625, -1, -.0625, .0625, 1.5, .0625},
  133. {-.5, .5, -.0625, .5, 1.5, -.03125}}},
  134. collision_box = {
  135. type = 'fixed',
  136. fixed = {-.0625, -1, -.0625, .0625, 1.5, .0625}},
  137. groups = {breakable=1},
  138. })
  139. minetest.register_node('furniture:traffic_sign_slow', {
  140. description = 'One Way',
  141. drawtype = 'mesh',
  142. mesh = 'furniture_traffic_sign_warning.obj',
  143. tiles = {'furniture_traffic_sign_post.png', 'furniture_traffic_sign_slow.png'},
  144. paramtype = 'light',
  145. paramtype2 = 'facedir',
  146. selection_box = {
  147. type = 'fixed',
  148. fixed = {{-.0625, -1, -.0625, .0625, 1.5, .0625},
  149. {-.5, .5, -.0625, .5, 1.5, -.03125}}},
  150. collision_box = {
  151. type = 'fixed',
  152. fixed = {-.0625, -1, -.0625, .0625, 1.5, .0625}},
  153. groups = {breakable=1},
  154. })