util.lua 671 B

12345678910111213141516171819202122232425
  1. function mesecon:swap_node(pos, name)
  2. local node = minetest.env:get_node(pos)
  3. local data = minetest.env:get_meta(pos):to_table()
  4. node.name = name
  5. minetest.env:add_node(pos, node)
  6. minetest.env:get_meta(pos):from_table(data)
  7. end
  8. function mesecon:move_node(pos, newpos)
  9. local node = minetest.env:get_node(pos)
  10. local meta = minetest.env:get_meta(pos):to_table()
  11. minetest.env:remove_node(pos)
  12. minetest.env:add_node(newpos, node)
  13. minetest.env:get_meta(pos):from_table(meta)
  14. end
  15. function mesecon:addPosRule(p, r)
  16. return {x = p.x + r.x, y = p.y + r.y, z = p.z + r.z}
  17. end
  18. function mesecon:cmpPos(p1, p2)
  19. return (p1.x == p2.x and p1.y == p2.y and p1.z == p2.z)
  20. end