trainworld_computercraft/computer/11/torment_nexus.lua
2025-05-22 20:51:25 +02:00

166 lines
No EOL
2.8 KiB
Lua

require("follow_rail")
PROGRESS_FILE = "torment_progress.txt"
function turnCW(dir)
if dir == 1 then
turtle.turnRight()
elseif dir == -1 then
turtle.turnLeft()
else
error("bad dir " .. tostring(dir))
end
end
function station_wheels()
print("beginning wheel building step")
local file = fs.open(PROGRESS_FILE, "r")
local progress = tonumber(file.readAll())
file.close()
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.turnLeft()
print(progress, "levels already done")
for i = 1,(progress*4) do
turtle.down()
end
print("right gear gutter")
for i = 1,4 do
turtle.digDown()
turtle.down()
turtle.dig()
end
turtle.forward()
-- currently under gears, at the bottom of the layer
turtle.dig()
turtle.forward()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.up()
turtle.turnLeft()
turtle.turnLeft()
-- cunter right side of wheel section
print("cutting wheel section")
local dir = 1
for slice = 1,16 do
for x = 1,6 do
turtle.digUp()
turtle.digDown()
turtle.dig()
turtle.forward()
end
turtle.digUp()
turtle.digDown()
turnCW(dir)
turtle.dig()
turtle.forward()
turnCW(dir)
dir = -dir
end
print("placing right wheels")
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
-- TODO select wheels
turtle.select(1)
for w = 1,16 do
turtle.back()
turtle.place()
end
print("placing right cogs")
-- TODO select cogs
turtle.select(2)
turtle.back()
turtle.place()
turtle.up()
turtle.place()
turtle.up()
turtle.place()
turtle.down()
turtle.down()
turtle.down()
turtle.place()
turtle.up()
print("moving to left gutter")
turtle.turnLeft()
for i = 1, 4 do
turtle.dig()
turtle.forward()
end
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.forward()
-- now in a wheel center
print("digging water gutter")
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.turnLeft()
turtle.down()
turtle.digDown()
for i = 1,15 do
turtle.forward()
turtle.digDown()
end
print("placing left wheels")
turtle.up()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnRight()
-- TODO select wheels
turtle.select(1)
for i = 1,16 do
turtle.back()
turtle.place()
end
turtle.back()
-- TODO select cogs
turtle.select(2)
turtle.digDown()
turtle.down()
print("placing left cogs")
for y = 1,4 do
turtle.dig()
turtle.place()
turtle.digUp()
turtle.up()
end
print("returning to start")
for i = 1,(progress*4) do
turtle.up()
end
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.turnLeft()
file = fs.open(PROGRESS_FILE, "w")
file.write(tostring(progress + 1))
file.close()
end
function station_wood() end
function station_andesite() end
function run()
--station_wood()
--follow_rail()
station_wheels()
--follow_rail()
--station_andesite()r
--follow_rail()
end
run()