deserialize_options.lua
local options = {
transform = {
rotate = {
angle = 90,
axis = "y",
disable_orientation = {
["default:sandstonebrick"] = true
}
},
replace = {
["default:dirt"] = "default:mese"
},
set_param2 = {
["unifiedbricks:brickblock"] = 15
}
},
on_metadata = function(pos, content_id, meta)
local nodename = minetest.get_name_from_content_id(content_id)
if nodename == "default:chest_locked" then
print(minetest.pos_to_string(pos), nodename)
meta:set_string("owner", "nobody")
end
end,
mode = "replace"
}
local filename = minetest.get_modpath("my_mod") .. "/schematics/my_catalog.zip"
local catalog, err = mapblock_lib.get_catalog(filename)
if err then
error(err)
end
local success, deser_err = catalog:deserialize({x=0,y=0,z=0}, {x=1,y=1,z=1})
if not success then
error(deser_err)
end
success, deser_err = catalog:deserialize({x=0,y=0,z=0}, {x=1,y=1,z=1}, options)
if not success then
error(deser_err)
end
catalog:deserialize_all({x=1,y=1,z=1})
catalog:deserialize_all({x=1,y=1,z=1}, {
delay = 1,
callback = function(count, micros)
print("Imported " .. count .. " mapblocks in " .. micros .. " us")
end,
progress_callback = function(f)
print("Progress: " .. (f*100) .. "%")
end,
error_callback = function(import_err)
error(import_err)
end
})
local deserFn, prep_err = catalog:prepare({x=0,y=0,z=0}, options)
if prep_err then
error(prep_err)
end
deserFn({x=1,y=1,z=1})