function RoomPackager.RegionsFromBasePlate(z,T)local b=z:TopCornersOfBasePlate(T)local W=b[1]local J=W.X local K=W.Z local I=W.X local L=W.Z for T,z in pairs(b)do J=math.min(J,z.X)K=math.min(K,z.Z)I=math.max(I,z.X)L=math.max(L,z.Z)end local A=b[1].Y local i=Vector3.new(J,A,K)local d=A+70 local e=Vector3.new(I,d,L)local q=math.floor(100000/(math.abs(I-J)*math.abs(L-K)))local s={}local U=A while U-A<70 do U=U+q i=Vector3.new(i.x,U-q,i.z)e=Vector3.new(e.x,U,e.z)table.insert(s,Region3.new(i,e))end return s end
--this returns a region3 that lines up on top of the baseplate to capture
--whatever room has been constructed on top of it, it is smart enough
--to capture a room that has been less-than-ideally set up
function RoomPackager:RegionsFromBasePlate(basePlate)
	local topCorners = self:TopCornersOfBasePlate(basePlate)

	--we farm the min and max x's and z's from the top corners
	--to get x and z coordinates for the region3 that will contain the room
	--we choose an arbitrary corner so that the initial values are in the data set
	local arbitraryCorner = topCorners[1]
	local minX = arbitraryCorner.X
	local minZ = arbitraryCorner.Z
	local maxX = arbitraryCorner.X
	local maxZ = arbitraryCorner.Z
	for _, corner in pairs(topCorners) do
		minX = math.min(minX, corner.X)
		minZ = math.min(minZ, corner.Z)
		maxX = math.max(maxX, corner.X)
		maxZ = math.max(maxZ, corner.Z)
	end

	--construct the region using these new corners we have constructed
	--keeping in mind that all corners in topCorners *should* have the same y value
	local minY = topCorners[1].Y
	local lowerCorner = Vector3.new(minX, minY, minZ)
	local maxY = minY + 70
	local upperCorner = Vector3.new(maxX, maxY, maxZ)

	local segmentHeight = math.floor(100000 / (math.abs(maxX - minX) * math.abs(maxZ - minZ)))

	local regions = {}

	local currentHeight = minY
	while currentHeight - minY < 70 do
		currentHeight = currentHeight + segmentHeight
		lowerCorner = Vector3.new(lowerCorner.x, currentHeight - segmentHeight, lowerCorner.z)
		upperCorner = Vector3.new(upperCorner.x, currentHeight, upperCorner.z)
		table.insert(regions, Region3.new(lowerCorner, upperCorner))
	end

	return regions
end
