minetest.register_chatcommand("creative_region", { params = " , , ", description = "Set a creative region from a to b", privs = {server = true}, func = function(name, param) local player = minetest.get_player_by_name(name) if not player then return false, "Player not found" end local found, _, x1, y1, z1, x2, y2, z2, region_name = param:find("^([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)%s*,%s*([+-]?%d+)%s+([+-]?%d+)%s+([+-]?%d+)%s*,%s*(.+)$") if not found then return false, "Syntax error" end local edge1 = { x=tonumber(x1), y=tonumber(y1), z=tonumber(z1) } local edge2 = { x=tonumber(x2), y=tonumber(y2), z=tonumber(z2) } local data = region_name local astore_id = creative_regions.astore:insert_area(edge1, edge2, tostring(data)) if astore_id then creative_regions.set_region_privs("r"..tostring(astore_id), nil) minetest.chat_send_player(name, "[creative_regions] New region set. ID: " .. "r"..astore_id) creative_regions.save_regions() return true, "Done" else return false, "Failed" end end, }) minetest.register_chatcommand("creative_region_privs", { params = ", ", description = "Set privstring for creative region", privs = {server = true}, func = function(name, param) local player = minetest.get_player_by_name(name) if not player then return false, "Player not found" end local found, _, region_id, privstring = param:find("^([ra]%d+)%s*,%s*(.+)$") if not found or not region_id or not privstring then return false, "Syntax error" end if privstring == "nil" then privstring = nil end creative_regions.set_region_privs(tostring(region_id), privstring) minetest.chat_send_player(name, "[creative_regions] Privstring set for region " .. region_id .. ": " .. privstring) creative_regions.save_regions() return true, "Done" end, }) minetest.register_chatcommand("creative_region_rm", { params = "", description = "Remove a creative region", privs = {server = true}, func = function(name, param) local player = minetest.get_player_by_name(name) if not player then return false, "Player not found" end local found, _, region_id = param:find("^(r%d+)%s*$") if not found or not region_id then return false, "Syntax error" end local astore_id = tonumber(string.sub(region_id, 2)) local success = creative_regions.astore:remove_area(astore_id) if success then minetest.chat_send_player(name, "[creative_regions] Region " .. region_id .. "removed") creative_regions.set_region_privs(tostring(region_id), nil) else minetest.chat_send_player(name, "Failed to remove region " .. region_id) return false, "Region not found" end creative_regions.save_regions() return true, "Done." end, })