-
Notifications
You must be signed in to change notification settings - Fork 1
/
patch.spec.lua
45 lines (34 loc) · 1.14 KB
/
patch.spec.lua
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
37
38
39
40
41
42
43
44
45
mtt.register("patch backend", function(callback)
local chunk_pos = { x=0, y=0, z=0 }
local path = minetest.get_worldpath() .. "/unpatched"
minetest.mkdir(path)
mapsync.register_backend("my-backend", {
type = "fs",
path = path
})
-- write chunk
local success = mapsync.save(chunk_pos)
assert(success)
-- unregister fs backend
mapsync.unregister_backend("my-backend")
local patch_path = minetest.get_worldpath() .. "/patched"
minetest.mkdir(patch_path)
mapsync.register_backend("my-patched-backend", {
type = "patch",
path = path,
patch_path = patch_path
})
minetest.set_node({ x=10, y=10, z=10 }, { name = "default:obsidianbrick" })
-- write patch
success = mapsync.save(chunk_pos)
assert(success)
-- get patch handler
local patch_backend_def = mapsync.get_backend("my-patched-backend")
-- apply patches back to shadowed backend
mapsync.apply_patches(patch_backend_def, function(chunk_count)
assert(chunk_count == 1)
-- cleanup
mapsync.unregister_backend("my-patched-backend")
callback()
end)
end)