Modified moveto in preparation for circumnavigation.
This commit is contained in:
		@@ -271,7 +271,6 @@ local function attemptStartTask(name, f, ...)
 | 
				
			|||||||
	taskArgs = arg
 | 
						taskArgs = arg
 | 
				
			||||||
end	
 | 
					end	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
-- Actions
 | 
					-- Actions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function determinePosition()
 | 
					local function determinePosition()
 | 
				
			||||||
@@ -366,7 +365,7 @@ local function moveBy(delta, forward, right)
 | 
				
			|||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function moveTo(dest, range)
 | 
					local function moveTo(dest)
 | 
				
			||||||
    sendLog(MOVETO, "Attempting to move by (" .. dest.x .. "," .. dest.y .. "," .. dest.z .. ") (x,y,z).")
 | 
					    sendLog(MOVETO, "Attempting to move by (" .. dest.x .. "," .. dest.y .. "," .. dest.z .. ") (x,y,z).")
 | 
				
			||||||
	if position == nil or heading == nil then
 | 
						if position == nil or heading == nil then
 | 
				
			||||||
		sendLog(FAILED, "Position or heading is invalid.")
 | 
							sendLog(FAILED, "Position or heading is invalid.")
 | 
				
			||||||
@@ -376,8 +375,8 @@ local function moveTo(dest, range)
 | 
				
			|||||||
	local oldPos = nil
 | 
						local oldPos = nil
 | 
				
			||||||
	while not vectorEqual(dest, position) do
 | 
						while not vectorEqual(dest, position) do
 | 
				
			||||||
		if oldPos ~= nil and vectorEqual(oldPos, position) then
 | 
							if oldPos ~= nil and vectorEqual(oldPos, position) then
 | 
				
			||||||
			sendLog(FAILED, "Cannot proceed to due obstacle.")
 | 
								sendLog(FAILED, "Cannot proceed to due obstacle. XYZ being blocked: " .. xBlocked .. "," .. yBlocked .. "," .. zBlocked)
 | 
				
			||||||
			return
 | 
								break
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		oldPos = vector.new(position.x, position.y, position.z);
 | 
							oldPos = vector.new(position.x, position.y, position.z);
 | 
				
			||||||
		if position.x ~= dest.x then
 | 
							if position.x ~= dest.x then
 | 
				
			||||||
@@ -385,13 +384,13 @@ local function moveTo(dest, range)
 | 
				
			|||||||
				sendLog(FAILED, "Unable to orient for X axis.")
 | 
									sendLog(FAILED, "Unable to orient for X axis.")
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
			attemptMoveForward()
 | 
								xblocked = attemptMoveForward()
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		if position.y ~= dest.y then
 | 
							if position.y ~= dest.y then
 | 
				
			||||||
			if dest.y - position.y > 0 then
 | 
								if dest.y - position.y > 0 then
 | 
				
			||||||
				attemptMoveUp()
 | 
									yBlocked = attemptMoveUp()
 | 
				
			||||||
			else
 | 
								else
 | 
				
			||||||
				attemptMoveDown()
 | 
									yBlocked = attemptMoveDown()
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		if position.z ~= dest.z then
 | 
							if position.z ~= dest.z then
 | 
				
			||||||
@@ -399,7 +398,7 @@ local function moveTo(dest, range)
 | 
				
			|||||||
				sendLog(FAILED, "Unable to orient for Z axis.")
 | 
									sendLog(FAILED, "Unable to orient for Z axis.")
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
			attemptMoveForward()
 | 
								zBlocked = attemptMoveForward()
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user