min_max.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. -- test ABMs with min_y and max_y
  2. local S = core.get_translator("testnodes")
  3. -- ABM min_y node
  4. core.register_node("testabms:min_y", {
  5. description = S("Node for test ABM min_y."),
  6. drawtype = "normal",
  7. tiles = { "testabms_wait_node.png" },
  8. groups = { dig_immediate = 3 },
  9. on_construct = function (pos)
  10. local meta = core.get_meta(pos)
  11. meta:set_string("infotext", "Waiting for ABM testabms:min_y at y "..pos.y.." with min_y = 0")
  12. end,
  13. })
  14. core.register_abm({
  15. label = "testabms:min_y",
  16. nodenames = "testabms:min_y",
  17. interval = 10,
  18. chance = 1,
  19. min_y = 0,
  20. action = function (pos)
  21. core.swap_node(pos, {name="testabms:after_abm"})
  22. local meta = core.get_meta(pos)
  23. meta:set_string("infotext", "ABM testabsm:min_y changed this node.")
  24. end
  25. })
  26. -- ABM max_y node
  27. core.register_node("testabms:max_y", {
  28. description = S("Node for test ABM max_y."),
  29. drawtype = "normal",
  30. tiles = { "testabms_wait_node.png" },
  31. groups = { dig_immediate = 3 },
  32. on_construct = function (pos)
  33. local meta = core.get_meta(pos)
  34. meta:set_string("infotext", "Waiting for ABM testabms:max_y at y "..pos.y.." with max_y = 0")
  35. end,
  36. })
  37. core.register_abm({
  38. label = "testabms:max_y",
  39. nodenames = "testabms:max_y",
  40. interval = 10,
  41. chance = 1,
  42. max_y = 0,
  43. action = function (pos)
  44. core.swap_node(pos, {name="testabms:after_abm"})
  45. local meta = core.get_meta(pos)
  46. meta:set_string("infotext", "ABM testabsm:max_y changed this node.")
  47. end
  48. })