summaryrefslogtreecommitdiff
path: root/worldedit/compatibility.lua
blob: e44e43b98e76f4d24f3eaf35af1b30d666dcc54f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
worldedit = worldedit or {}
local minetest = minetest --local copy of global

worldedit.allocate_old = worldedit.allocate

worldedit.deserialize_old = worldedit.deserialize

worldedit.metasave = function(pos1, pos2, filename)
	local file, err = io.open(filename, "wb")
	if err then return 0 end
	local data, count = worldedit.serialize(pos1, pos2)
	file:write(data)
	file:close()
	return count
end

worldedit.metaload = function(originpos, filename)
	filename = minetest.get_worldpath() .. "/schems/" .. file .. ".wem"
	local file, err = io.open(filename, "wb")
	if err then return 0 end
	local data = file:read("*a")
	return worldedit.deserialize(originpos, data)
end

worldedit.scale = function(pos1, pos2, factor)
	return worldedit.stretch(pos1, pos2, factor, factor, factor)
end

worldedit.valueversion = function(value)
	local version = worldedit.read_header(value)
	if not version or version > worldedit.LATEST_SERIALIZATION_VERSION then
		return 0
	end
	return version
end