compatibility.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. --- Compatibility functions.
  2. -- @module worldedit.compatibility
  3. local function deprecated(new_func)
  4. local info = debug.getinfo(1, "n")
  5. local msg = "worldedit." .. info.name .. "() is deprecated."
  6. if new_func then
  7. msg = msg .. " Use worldedit." .. new_func .. "() instead."
  8. end
  9. minetest.log("deprecated", msg)
  10. end
  11. worldedit.allocate_old = worldedit.allocate
  12. worldedit.deserialize_old = worldedit.deserialize
  13. function worldedit.metasave(pos1, pos2, filename)
  14. deprecated("save")
  15. local file, err = io.open(filename, "wb")
  16. if err then return 0 end
  17. local data, count = worldedit.serialize(pos1, pos2)
  18. file:write(data)
  19. file:close()
  20. return count
  21. end
  22. function worldedit.metaload(originpos, filename)
  23. deprecated("load")
  24. filename = minetest.get_worldpath() .. "/schems/" .. file .. ".wem"
  25. local file, err = io.open(filename, "wb")
  26. if err then return 0 end
  27. local data = file:read("*a")
  28. return worldedit.deserialize(originpos, data)
  29. end
  30. function worldedit.scale(pos1, pos2, factor)
  31. deprecated("stretch")
  32. return worldedit.stretch(pos1, pos2, factor, factor, factor)
  33. end
  34. function worldedit.valueversion(value)
  35. deprecated("read_header")
  36. local version = worldedit.read_header(value)
  37. if not version or version > worldedit.LATEST_SERIALIZATION_VERSION then
  38. return 0
  39. end
  40. return version
  41. end
  42. function worldedit.replaceinverse(pos1, pos2, search_node, replace_node)
  43. deprecated("replace")
  44. return worldedit.replace(pos1, pos2, search_node, replace_node, true)
  45. end
  46. function worldedit.clearobjects(...)
  47. deprecated("clear_objects")
  48. return worldedit.clear_objects(...)
  49. end
  50. function worldedit.hollow_sphere(pos, radius, node_name)
  51. deprecated("sphere")
  52. return worldedit.sphere(pos, radius, node_name, true)
  53. end
  54. function worldedit.hollow_dome(pos, radius, node_name)
  55. deprecated("dome")
  56. return worldedit.dome(pos, radius, node_name, true)
  57. end
  58. function worldedit.hollow_cylinder(pos, axis, length, radius, node_name)
  59. deprecated("cylinder")
  60. return worldedit.cylinder(pos, axis, length, radius, node_name, true)
  61. end