-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata.spec.lua
More file actions
32 lines (24 loc) · 782 Bytes
/
data.spec.lua
File metadata and controls
32 lines (24 loc) · 782 Bytes
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
mtt.register("data", function(callback)
local path = minetest.get_worldpath() .. "/data"
minetest.mkdir(path)
mapsync.register_data_backend({
type = "fs",
path = path
})
mapsync.save_data("x", { y = 1 })
local value = mapsync.load_data("x")
assert(value)
assert(value.y == 1)
assert(not mapsync.load_data("y"))
-- data file
assert(not mapsync.get_data_file("non-existent-file.txt")) -- defaults to read-mode
assert(mapsync.get_data_file("myfile2.txt", "w"))
-- write to data file
assert(not mapsync.get_data_file("myfile3.txt"))
local f = mapsync.get_data_file("myfile3.txt", "w")
assert(f)
f:write("stuff")
f:close()
assert(mapsync.get_data_file("myfile3.txt"))
callback()
end)