Skip to content

Instantly share code, notes, and snippets.

@johnkraczek
Last active March 5, 2023 10:38
Show Gist options
  • Save johnkraczek/0d3f8c47ed0eb624076a90436fe8f83c to your computer and use it in GitHub Desktop.
Save johnkraczek/0d3f8c47ed0eb624076a90436fe8f83c to your computer and use it in GitHub Desktop.
circleturtle.lua
args = { ... }
D = true
if (args[2] == "--up") then
D = false
end
X = 1
Y = 0
Z = 0
R = 0
R = tonumber(args[1])
function CheckR(arg1)
print(arg1 .. ": X:" .. X .. " Y:" .. Y .. " Z:" .. Z .. " R:" .. R)
if (X * X + Y * Y + Z * Z > R * R) then
-- print("returned true")
return true;
end
-- print("returned false")
return false;
end
function MoveForward()
if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
turtle.refuel()
end
if turtle.detect() then
turtle.dig()
end
-- print("Moving Forward")
turtle.forward()
X = X + 1
-- print("Updating X to " .. X)
end
function ReturnX()
while X > 1 do
turtle.back()
X = X - 1
end
turtle.turnRight()
if turtle.detect() then
-- print("Digging Forward")
turtle.dig()
end
-- print("Moving Forward")
turtle.forward()
Y = Y + 1
turtle.turnLeft()
end
function ReturnY()
turtle.turnRight()
while Y > 0 do
turtle.back()
Y = Y - 1
end
end
if (R > 1) then
for h = R, 0, -1 do
for d = 1, 4, 1 do
while not (CheckR("chkY")) do
while not (CheckR("chkX")) do
MoveForward()
end
print("Start Return X")
ReturnX()
end
print("Should Be Zero: X:" .. X .. " Y:" .. Y .. " Z:" .. Z .. " R:" .. R)
print("Done With Quadrant")
ReturnY()
end
Z = Z + 1
if (D) then
if turtle.detectDown() then
turtle.digDown()
end
turtle.down()
else
if turtle.detectUp() then
turtle.digUp()
end
turtle.up()
end
end
end
@johnkraczek
Copy link
Author

Now working Sphere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment