Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Bridge build program")
- print("")
- print("Place turtle facing away.")
- print("Turtle will build a 4x4 structure")
- print("using the blocks in the corresponding")
- print("square of its interface. Put a torch")
- print("in the slot the corresponds to the")
- print("turtle's relative location.")
- print("Turtle will keep building until the")
- print("largest stack is out of blocks.")
- -- find the turtle's relative location
- local turtleslot = -1
- local maxstack = 0
- for x=1,16 do
- if turtle.getItemCount(x) > 0 then
- if(turtle.getItemDetail(x).name == "minecraft:torch") then
- turtleslot = x
- end
- if turtle.getItemCount(x) > maxstack then
- maxstack = turtle.getItemCount(x)
- end
- end
- end
- if turtleslot == -1 then
- error("Must have a torch in the turtle's inventory")
- end
- -- move turtle to the upper left
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- turtle.select(turtleslot)
- while turtle.getSelectedSlot() > 4 do
- turtle.up()
- turtle.select(turtle.getSelectedSlot() - 4)
- end
- while turtle.getSelectedSlot() > 1 do
- turtle.forward()
- turtle.select(turtle.getSelectedSlot() - 1)
- end
- turtle.turnLeft()
- -- place blocks
- for z=1,maxstack do
- if z ~= 1 then
- turtle.turnRight()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- for x=1,4 do
- if x ~= 1 then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- for y=1,4 do
- if y ~= 1 then
- turtle.down()
- end
- local blockslot = (x-1)+((y-1)*4)+1
- if blockslot ~= turtleslot then
- turtle.select(blockslot)
- turtle.place()
- end
- end
- -- return to top
- turtle.up()
- turtle.up()
- turtle.up()
- end
- -- return to left
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- end
- -- move turtle back to starting spot
- turtle.select(1)
- while turtleslot - turtle.getSelectedSlot() >= 4 do
- turtle.down()
- turtle.select(turtle.getSelectedSlot() + 4)
- end
- turtle.turnLeft()
- while turtleslot - turtle.getSelectedSlot() >= 1 do
- turtle.forward()
- turtle.select(turtle.getSelectedSlot() + 1)
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- turtle.turnRight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement