Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Zero origin dead reckoning movement in 20 lines
- -- Always face forward, x & y & z are relative to our initial position
- -- Positive X is right of front, positive Y is forward, positive Z is up
- current = { x=0, y=0, z=0 }
- move = { x = { forward = turtle.forward, back = turtle.back },
- y = { forward = turtle.forward, back = turtle.back },
- z = { forward = turtle.up, back = turtle.down }}
- function walkAxis(axis, destinationCoord)
- delta = destinationCoord - current[axis]
- if delta == 0 then return nil end
- (destinationCoord > current[axis] and move[axis]['forward'] or move[axis]['back'])()
- current[axis] = (delta / math.abs(delta)) + current[axis]
- walkAxis(axis, destinationCoord)
- end
- function walkTo(x,y,z)
- if x ~= current['x'] then
- turtle.turnRight()
- walkAxis('x', x)
- turtle.turnLeft()
- end
- walkAxis('y', y)
- walkAxis('z', z)
- end
- -- Inventory requirements by slot
- -- Slot Qty Item
- items = {
- { qty = 1, desc = "Steam line"},
- { qty = 8, desc = "Steam Injector"},
- { qty = 64, desc = "Turbine Housing"},
- { qty = 64, desc = "Turbine Housing"},
- { qty = 64, desc = "Turbine Housing"},
- { qty = 20, desc = "Turbine Housing"},
- { qty = 64, desc = "Turbine Blades"},
- { qty = 64, desc = "Turbine Blades"},
- { qty = 8, desc = "Turbine Blades"},
- { qty = 7, desc = "HP turbine block"}}
- for slot, item in ipairs(items) do
- count = turtle.getItemCount(slot)
- if count < item.qty then
- print ("Have " .. count .. "in slot " .. slot .. ", expected " .. item.qty .. " of " .. item.desc)
- end
- end
- -- Pattern is in x, z, y format.
- pattern = {
- {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 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 0, 0, 6, 6, 9, 9, 9, 9, 9, 6, 6, 0, 0 },
- { 0, 0, 0, 6, 6, 6, 9, 6, 6, 6, 0, 0, 0 },
- { 0, 0, 0, 0, 6, 6, 6, 6, 6, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
- -- MAIN --
- -- CUSTOM: I start the turtle on the ground, I need to refuel from slot 16 and gain height before beginning
- turtle.select(16)
- turtle.refuel(64)
- for height = 1, 25 do
- turtle.up()
- end
- -- END CUSTOM
- -- Build the pattern
- for y = 1, #pattern do
- for z = 1, #pattern[y] do
- for x = z % 2 == 0 and 1 or #pattern[y][z], z % 2 == 0 and #pattern[y][z] or 1, z % 2 == 0 and 1 or -1 do
- item = pattern[y][z][x]
- if item ~= 0 then
- walkTo(x, -y, -z)
- turtle.select(item)
- turtle.place()
- end
- end
- end
- end
- -- CUSTOM: Step back on completion
- for step = 1, 5 do
- turtle.back()
- end
- -- END CUSTOM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement