nodes.lua 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. --[[
  2. ontime_clocks mod for Minetest - Clock nodes displaying ingame time
  3. (c) Pierre-Yves Rollo
  4. This file is part of ontime_clocks.
  5. ontime_clocks is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. ontime_clocks is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with ontime_clocks. If not, see <http://www.gnu.org/licenses/>.
  15. --]]
  16. local S = ontime_clocks.intllib
  17. -- Green digital clock
  18. minetest.register_node("ontime_clocks:green_digital", {
  19. description = S("Green digital clock"),
  20. inventory_image = "ontime_clocks_green_digital_inventory.png",
  21. wield_image = "ontime_clocks_green_digital_inventory.png",
  22. paramtype = "light",
  23. paramtype2 = "wallmounted",
  24. drawtype = "nodebox",
  25. node_box = {
  26. type = "wallmounted",
  27. wall_side = { -0.5, -3/16, -7/16, -13/32, 7/32, 7/16 },
  28. wall_top = { -7/16, 0.5, -7/32, 7/16, 13/32, 3/16 },
  29. wall_bottom = { -7/16, -0.5, -3/16, 7/16, -13/32, 7/32 },
  30. },
  31. tiles = {"ontime_clocks_digital.png"},
  32. groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
  33. display_entities = {
  34. ["ontime_clocks:display"] = {
  35. depth = 13/32 - 0.01,
  36. on_display_update = function(pos, objref)
  37. objref:set_properties(
  38. ontime_clocks.get_digital_properties(
  39. "#040", "#0F0", ontime_clocks.get_h24(), ontime_clocks.get_m12()))
  40. end },
  41. },
  42. on_place = display_api.on_place,
  43. on_construct = display_api.on_construct,
  44. on_destruct = display_api.on_destruct,
  45. on_rotate = display_api.on_rotate,
  46. })
  47. minetest.register_abm({
  48. nodenames = {"ontime_clocks:green_digital"},
  49. interval = 5,
  50. chance = 1,
  51. action = display_api.update_entities,
  52. })
  53. -- Red digital clock
  54. minetest.register_node("ontime_clocks:red_digital", {
  55. description = S("Red digital clock"),
  56. inventory_image = "ontime_clocks_red_digital_inventory.png",
  57. wield_image = "ontime_clocks_red_digital_inventory.png",
  58. paramtype = "light",
  59. paramtype2 = "wallmounted",
  60. drawtype = "nodebox",
  61. node_box = {
  62. type = "wallmounted",
  63. wall_side = { -0.5, -3/16, -7/16, -13/32, 7/32, 7/16 },
  64. wall_bottom = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },
  65. wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
  66. },
  67. tiles = {"ontime_clocks_digital.png"},
  68. groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
  69. display_entities = {
  70. ["ontime_clocks:display"] = {
  71. depth = 13/32 - 0.01,
  72. on_display_update = function(pos, objref)
  73. objref:set_properties(
  74. ontime_clocks.get_digital_properties(
  75. "#400", "#F00", ontime_clocks.get_h24(), ontime_clocks.get_m12()))
  76. end },
  77. },
  78. on_place = display_api.on_place,
  79. on_construct = display_api.on_construct,
  80. on_destruct = display_api.on_destruct,
  81. on_rotate = display_api.on_rotate,
  82. })
  83. minetest.register_abm({
  84. nodenames = {"ontime_clocks:red_digital"},
  85. interval = 5,
  86. chance = 1,
  87. action = display_api.update_entities,
  88. })
  89. minetest.register_node("ontime_clocks:white", {
  90. description = S("White clock"),
  91. inventory_image = "ontime_clocks_white_inventory.png",
  92. wield_image = "ontime_clocks_white_inventory.png",
  93. paramtype = "light",
  94. paramtype2 = "wallmounted",
  95. drawtype = "nodebox",
  96. node_box = {
  97. type = "wallmounted",
  98. wall_side = { -0.5, -7/16, -7/16, -6/16, 7/16, 7/16},
  99. wall_bottom = { -7/16, -0.5, -7/16, 7/16, -7/16, 7/16},
  100. wall_top = { -7/16, 0.5, -7/16, 7/16, 7/16, 7/16},
  101. },
  102. tiles = {"ontime_clocks_white.png"},
  103. groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
  104. display_entities = {
  105. ["ontime_clocks:display"] = {
  106. depth = 6/16 - 0.01,
  107. on_display_update = function(pos, objref)
  108. objref:set_properties(
  109. ontime_clocks.get_needles_properties(
  110. "#000", 36, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
  111. end },
  112. },
  113. on_place = display_api.on_place,
  114. on_construct = display_api.on_construct,
  115. on_destruct = display_api.on_destruct,
  116. on_rotate = display_api.on_rotate,
  117. })
  118. minetest.register_abm({
  119. nodenames = {"ontime_clocks:white"},
  120. interval = 5,
  121. chance = 1,
  122. action = display_api.update_entities,
  123. })
  124. minetest.register_node("ontime_clocks:frameless_black", {
  125. description = S("Frameless clock"),
  126. inventory_image = "ontime_clocks_frameless_inventory.png",
  127. wield_image = "ontime_clocks_frameless_inventory.png",
  128. paramtype = "light",
  129. paramtype2 = "wallmounted",
  130. drawtype = "nodebox",
  131. node_box = {
  132. type = "wallmounted",
  133. wall_side = { -0.5, -7/16, -7/16, -0.45, 7/16, 7/16 },
  134. wall_bottom = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },
  135. wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
  136. },
  137. tiles = {"ontime_clocks_frameless.png"},
  138. groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
  139. display_entities = {
  140. ["ontime_clocks:display"] = {
  141. depth = 7/16,
  142. on_display_update = function(pos, objref)
  143. objref:set_properties(
  144. ontime_clocks.get_needles_properties(
  145. "#000", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
  146. end },
  147. },
  148. on_place = display_api.on_place,
  149. on_construct = display_api.on_construct,
  150. on_destruct = display_api.on_destruct,
  151. on_rotate = display_api.on_rotate,
  152. })
  153. minetest.register_abm({
  154. nodenames = {"ontime_clocks:frameless_black"},
  155. interval = 5,
  156. chance = 1,
  157. action = display_api.update_entities,
  158. })
  159. minetest.register_node("ontime_clocks:frameless_gold", {
  160. description = S("Frameless gold clock"),
  161. inventory_image = "ontime_clocks_frameless_inventory.png^[colorize:#FF0",
  162. wield_image = "ontime_clocks_frameless_inventory.png^[colorize:#FF0",
  163. paramtype = "light",
  164. paramtype2 = "wallmounted",
  165. drawtype = "nodebox",
  166. node_box = {
  167. type = "wallmounted",
  168. wall_side = { -0.5, -7/16, -7/16, -0.45, 7/16, 7/16 },
  169. wall_bottom = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },
  170. wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
  171. },
  172. tiles = {"ontime_clocks_frameless.png^[colorize:#FF0"},
  173. groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
  174. display_entities = {
  175. ["ontime_clocks:display"] = {
  176. depth = 7/16,
  177. on_display_update = function(pos, objref)
  178. objref:set_properties(
  179. ontime_clocks.get_needles_properties(
  180. "#FF0", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
  181. end },
  182. },
  183. on_place = display_api.on_place,
  184. on_construct = display_api.on_construct,
  185. on_destruct = display_api.on_destruct,
  186. on_rotate = display_api.on_rotate,
  187. })
  188. minetest.register_abm({
  189. nodenames = {"ontime_clocks:frameless_gold"},
  190. interval = 5,
  191. chance = 1,
  192. action = display_api.update_entities,
  193. })
  194. minetest.register_node("ontime_clocks:frameless_white", {
  195. description = S("Frameless white clock"),
  196. inventory_image = "ontime_clocks_frameless_inventory.png^[colorize:#FFF",
  197. wield_image = "ontime_clocks_frameless_inventory.png^[colorize:#FFF",
  198. paramtype = "light",
  199. paramtype2 = "wallmounted",
  200. drawtype = "nodebox",
  201. node_box = {
  202. type = "wallmounted",
  203. wall_side = { -0.5, -7/16, -7/16, -0.45, 7/16, 7/16 },
  204. wall_bottom = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },
  205. wall_top = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
  206. },
  207. tiles = {"ontime_clocks_frameless.png^[colorize:#FFF"},
  208. groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
  209. display_entities = {
  210. ["ontime_clocks:display"] = {
  211. depth = 7/16,
  212. on_display_update = function(pos, objref)
  213. objref:set_properties(
  214. ontime_clocks.get_needles_properties(
  215. "#FFF", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
  216. end },
  217. },
  218. on_place = display_api.on_place,
  219. on_construct = display_api.on_construct,
  220. on_destruct = display_api.on_destruct,
  221. on_rotate = display_api.on_rotate,
  222. })
  223. minetest.register_abm({
  224. nodenames = {"ontime_clocks:frameless_white"},
  225. interval = 5,
  226. chance = 1,
  227. action = display_api.update_entities,
  228. })