Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Platform (1 wide)
- Created by Izzobot
- ]]--
- FUEL_SLOT = 1
- -- Functions
- function refuel()
- turtle.select(FUEL_SLOT)
- items = turtle.getItemCount(FUEL_SLOT)
- fuel = turtle.getFuelLevel(FUEL_SLOT)
- if fuel == 0 then -- When no fuel
- if items ~= 0 then
- print("Refuelling...")
- turtle.refuel(FUEL_SLOT)
- print("Refueled!")
- else -- If no fuel present
- print("Add more fuel to slot " .. FUEL_SLOT)
- error()
- end
- else
- print("Fuel level sufficient")
- end
- end
- function digForward()
- while turtle.detect() do
- turtle.dig()
- end
- end
- function moveForward()
- if turtle.getFuelLevel() == 0 then
- refuel()
- end
- while (not turtle.forward()) do
- if (turtle.detect()) then
- turtle.dig()
- else
- turtle.attack()
- end
- end
- end
- function placeDown()
- changeSlot()
- turtle.placeDown()
- end
- function placeUp()
- changeSlot()
- turtle.placeUp()
- end
- function placeForward()
- changeSlot()
- turtle.place()
- end
- function moveUp()
- if turtle.getFuelLevel() == 0 then
- refuel()
- end
- while turtle.up() == false do
- turtle.digUp()
- end
- end
- function moveDown()
- if turtle.getFuelLevel() == 0 then
- refuel()
- end
- while turtle.down() == false do
- turtle.digDown()
- end
- end
- function enoughItems()
- t = 0
- for slot=2,16 do -- Count the number of blocks
- t = t + turtle.getItemCount(slot)
- end
- if t < l then
- print("More blocks required.")
- error()
- end
- end
- function changeSlot()
- if turtle.getItemCount() == 0 then
- for i=2,16 do
- turtle.select(i)
- if turtle.getItemCount(i) ~= 0 then
- break
- end
- end
- end
- end
- -- Start of Code
- turtle.select(2)
- print(" ")
- print("[Platform 1 Wide]\n")
- io.write("Length: ")
- l = tonumber(read())
- print(" ")
- enoughItems()
- print("Building...")
- for i=1,l do
- digForward()
- moveForward()
- placeDown()
- end
- print("Platform complete.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement