end),\r
})\r
\r
+local function detect_misaligned_schematic(name, pos1, pos2)\r
+ pos1, pos2 = worldedit.sort_pos(pos1, pos2)\r
+ -- Check that allocate/save can position the schematic correctly\r
+ -- The expected behaviour is that the (0,0,0) corner of the schematic stays\r
+ -- sat pos1, this only works when the minimum position is actually present\r
+ -- in the schematic.\r
+ local node = minetest.get_node(pos1)\r
+ local have_node_at_origin = node.name ~= "air" and node.name ~= "ignore"\r
+ if not have_node_at_origin then\r
+ worldedit.player_notify(name,\r
+ "Warning: The schematic contains excessive free space and WILL be "..\r
+ "misaligned when allocated or loaded. To avoid this, shrink your "..\r
+ "area to cover exactly the nodes to be saved."\r
+ )\r
+ end\r
+end\r
+\r
minetest.register_chatcommand("/save", {\r
params = "<file>",\r
description = "Save the current WorldEdit region to \"(world folder)/schems/<file>.we\"",\r
end\r
local result, count = worldedit.serialize(worldedit.pos1[name],\r
worldedit.pos2[name])\r
+ detect_misaligned_schematic(name, worldedit.pos1[name], worldedit.pos2[name])\r
\r
local path = minetest.get_worldpath() .. "/schems"\r
-- Create directory if it does not already exist\r