1

Implement TestingController

This commit is contained in:
2025-10-05 21:42:19 +02:00
parent 819a8a81ef
commit 515042e711

View File

@ -23,19 +23,123 @@ end
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
function TestingController:TestSimpleMovement() function TestingController:TestRelativeMovementWithRelativeRotation()
print("Testing relative movement with relative rotation...")
-- N: BotCenter
self.controller:MoveRelative(3)
self.controller:TurnRelative(1) -- E: TopCenter
self.controller:MoveRelative(3)
self.controller:TurnRelative(2) -- W: TopRight
self.controller:MoveRelative(3)
self.controller:TurnRelative(10) -- E: TopCenter
self.controller:MoveRelative(3)
self.controller:TurnRelative(-3) -- S: TopRight
self.controller:MoveRelative(3)
self.controller:TurnRelative(1) -- W: BotRight
self.controller:MoveRelative(3)
self.controller:TurnRelative(1) -- N: BotCenter
print("The turtle should be in its original location.")
print("Press Enter to continue")
_ = io.read()
end end
function TestingController:TestComplexMovement() function TestingController:TestRelativeMovementWithAbsoluteRotation()
print("Testing relative movement with absolute rotation...")
-- N: BotCenter
self.controller:MoveRelative(3)
self.controller:TurnToDirection(Direction.EAST) -- E: TopCenter
self.controller:MoveRelative(3)
self.controller:TurnToDirection(Direction.WEST) -- W: TopRight
self.controller:MoveRelative(3)
self.controller:TurnToDirection(Direction.EAST) -- E: TopCenter
self.controller:MoveRelative(3)
self.controller:TurnToDirection(Direction.SOUTH) -- S: TopRight
self.controller:MoveRelative(3)
self.controller:TurnToDirection(Direction.WEST) -- W: BotRight
self.controller:MoveRelative(3)
self.controller:TurnToDirection(Direction.NORTH) -- N: BotCenter
print("The turtle should be in its original location.")
print("Press Enter to continue")
_ = io.read()
end end
function TestingController:TestUnloading() function TestingController:TestAbsoluteMovementWithoutStack()
print("Testing absolute movement without stack...")
-- N: BotCenter
self.controller:MoveToPosition(0, 0, 3, Direction.EAST) -- E: TopCenter
_ = io.read()
self.controller:MoveToPosition(3, 0, 3, Direction.WEST) -- W: TopRight
_ = io.read()
self.controller:MoveToPosition(0, 0, 3, Direction.EAST) -- E: TopCenter
_ = io.read()
self.controller:MoveToPosition(3, 0, 3, Direction.SOUTH) -- S: TopRight
_ = io.read()
self.controller:MoveToPosition(3, 0, 0, Direction.WEST) -- W: BotRight
_ = io.read()
self.controller:MoveToPosition(0, 0, 0, Direction.NORTH) -- N: BotCenter
print("The turtle should be in its original location.")
print("Press Enter to continue")
_ = io.read()
end
function TestingController:TestAbsoluteMovementWithStack()
print("Testing absolute movement with stack...")
-- N: BotCenter
self.controller:MoveToPosition(0, 0, 3, Direction.EAST) -- E: TopCenter
_ = io.read()
self.controller:MoveBack() -- N: BotCenter
_ = io.read()
self.controller:MoveToPosition(3, 0, 3, Direction.WEST) -- W: TopRight
_ = io.read()
self.controller:MoveBack() -- N: BotCenter
print("The turtle should be in its original location.")
print("Press Enter to continue")
_ = io.read()
end
function TestingController:TestUnstocking()
print("Testing inventory unloading...")
print("Please fill multiple inventory slots with items.")
_ = io.read()
self.controller:MoveToPosition(3, 0, 3, Direction.WEST)
_ = io.read()
self.controller:UnstockIfFull(true)
_ = io.read()
self.controller:MoveBack()
print("The turtle should be in its original location.")
print("Press Enter to continue")
_ = io.read()
end end
function TestingController:TestRefueling() function TestingController:TestRefueling()
print("Testing refueling...")
print("Please fill multiple inventory slots with items.")
_ = io.read()
self.controller:MoveToPosition(3, 0, 3, Direction.WEST)
_ = io.read()
self.controller:RefuelIfEmpty(true)
_ = io.read()
self.controller:MoveBack()
print("The turtle should be in its original location.")
print("Press Enter to continue")
_ = io.read()
end end
@ -46,11 +150,53 @@ end
function TestingController:Run() function TestingController:Run()
self.controller:Configure() self.controller:Configure()
self.controller:DisableMining()
self:TestSimpleMovement() print("There are multiple tests available:")
self:TestComplexMovement() print("1: Relative movement with relative rotation")
self:TestUnloading() print("2: Relative movement with absolute rotation")
self:TestRefueling() print("3: Absolute movement without stack")
print("4: Absolute movement with stack")
print("5: All movement tests")
print("6: Unloading")
print("7: Refueling")
print("8: All non-movement tests")
print("9: All tests")
local choice = 0
while choice < 1 or choice > 9 do
print("Choose a test by entering its number:")
choice = tonumber(io.read()) or 0
end
if choice == 1 then
self:TestRelativeMovementWithRelativeRotation()
elseif choice == 2 then
self:TestRelativeMovementWithAbsoluteRotation()
elseif choice == 3 then
self:TestAbsoluteMovementWithoutStack()
elseif choice == 4 then
self:TestAbsoluteMovementWithStack()
elseif choice == 5 then
self:TestRelativeMovementWithRelativeRotation()
self:TestRelativeMovementWithAbsoluteRotation()
self:TestAbsoluteMovementWithoutStack()
self:TestAbsoluteMovementWithStack()
elseif choice == 6 then
self:TestUnstocking()
elseif choice == 7 then
self:TestRefueling()
elseif choice == 8 then
self:TestUnstocking()
self:TestRefueling()
elseif choice == 9 then
self:TestRelativeMovementWithRelativeRotation()
self:TestRelativeMovementWithAbsoluteRotation()
self:TestAbsoluteMovementWithoutStack()
self:TestAbsoluteMovementWithStack()
self:TestUnstocking()
self:TestRefueling()
end
end end