mirror of
				https://github.com/minetest-mods/areas.git
				synced 2025-11-04 06:35:28 +01:00 
			
		
		
		
	Add move_area command
This commit is contained in:
		@@ -239,7 +239,6 @@ minetest.register_chatcommand("change_owner", {
 | 
				
			|||||||
	description = "Change the owner of an area using it's ID",
 | 
						description = "Change the owner of an area using it's ID",
 | 
				
			||||||
	func = function(name, param)
 | 
						func = function(name, param)
 | 
				
			||||||
		local id, newOwner = param:match("^(%d+)%s(%S+)$")
 | 
							local id, newOwner = param:match("^(%d+)%s(%S+)$")
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if not id then
 | 
							if not id then
 | 
				
			||||||
			return false, "Invalid usage, see"
 | 
								return false, "Invalid usage, see"
 | 
				
			||||||
					.." /help change_owner."
 | 
										.." /help change_owner."
 | 
				
			||||||
@@ -270,7 +269,6 @@ minetest.register_chatcommand("area_open", {
 | 
				
			|||||||
	description = "Toggle an area open (anyone can interact) or closed",
 | 
						description = "Toggle an area open (anyone can interact) or closed",
 | 
				
			||||||
	func = function(name, param)
 | 
						func = function(name, param)
 | 
				
			||||||
		local id = tonumber(param)
 | 
							local id = tonumber(param)
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if not id then
 | 
							if not id then
 | 
				
			||||||
			return false, "Invalid usage, see /help area_open."
 | 
								return false, "Invalid usage, see /help area_open."
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
@@ -287,3 +285,31 @@ minetest.register_chatcommand("area_open", {
 | 
				
			|||||||
	end
 | 
						end
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					minetest.register_chatcommand("move_area", {
 | 
				
			||||||
 | 
						params = "<ID>",
 | 
				
			||||||
 | 
						description = "Move (or resize) an area to the current positions.",
 | 
				
			||||||
 | 
						privs = areas.adminPrivs,
 | 
				
			||||||
 | 
						func = function(name, param)
 | 
				
			||||||
 | 
							local id = tonumber(param)
 | 
				
			||||||
 | 
							if not id then
 | 
				
			||||||
 | 
								return false, "Invalid usage, see /help move_area."
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							local area = areas.areas[id]
 | 
				
			||||||
 | 
							if not area then
 | 
				
			||||||
 | 
								return false, "Area does not exist."
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							local pos1, pos2 = areas:getPos(name)
 | 
				
			||||||
 | 
							if not pos1 then
 | 
				
			||||||
 | 
								return false, "You need to select an area first."
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							area.pos1 = pos1
 | 
				
			||||||
 | 
							area.pos2 = pos2
 | 
				
			||||||
 | 
							areas:save()
 | 
				
			||||||
 | 
							return true, "Area successfully moved."
 | 
				
			||||||
 | 
						end,
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user