legacy.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. local ground_dir = {
  2. [0] = {x = 0, y = -1, z = 0},
  3. {x = 0, y = 0, z = -1},
  4. {x = 0, y = 0, z = 1},
  5. {x = -1, y = 0, z = 0},
  6. {x = 1, y = 0, z = 0},
  7. {x = 0, y = 1, z = 0},
  8. }
  9. minetest.register_lbm({
  10. label = "Upgrade legacy pistons pointing up",
  11. name = "mesecons_pistons:replace_legacy_piston_up",
  12. nodenames = {
  13. "mesecons_pistons:piston_up_normal_off",
  14. "mesecons_pistons:piston_up_normal_on",
  15. "mesecons_pistons:piston_up_pusher_normal",
  16. "mesecons_pistons:piston_up_sticky_off",
  17. "mesecons_pistons:piston_up_sticky_on",
  18. "mesecons_pistons:piston_up_pusher_sticky",
  19. },
  20. run_at_every_load = false,
  21. action = function(pos, node)
  22. local dir = ground_dir[math.floor(node.param2/4)]
  23. node.param2 = minetest.dir_to_facedir(dir, true)
  24. node.name = node.name:sub(1, 24)..node.name:sub(28)
  25. minetest.swap_node(pos, node)
  26. end,
  27. })
  28. minetest.register_lbm({
  29. label = "Upgrade legacy pistons pointing down",
  30. name = "mesecons_pistons:replace_legacy_piston_down",
  31. nodenames = {
  32. "mesecons_pistons:piston_down_normal_off",
  33. "mesecons_pistons:piston_down_normal_on",
  34. "mesecons_pistons:piston_down_pusher_normal",
  35. "mesecons_pistons:piston_down_sticky_off",
  36. "mesecons_pistons:piston_down_sticky_on",
  37. "mesecons_pistons:piston_down_pusher_sticky",
  38. },
  39. run_at_every_load = false,
  40. action = function(pos, node)
  41. local dir = vector.multiply(ground_dir[math.floor(node.param2/4)], -1)
  42. node.param2 = minetest.dir_to_facedir(dir, true)
  43. node.name = node.name:sub(1, 24)..node.name:sub(30)
  44. minetest.swap_node(pos, node)
  45. end,
  46. })