Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function printheader()
- term.clear()
- term.setCursorPos(1,1)
- print("-----------------------------------")
- print("FlatIt | RXDV Laboratories")
- print("-----------------------------------")
- end
- local function invcheck()
- while true do
- for n=1,9 do
- if turtle.getItemCount(n) > 0 then
- return n
- end
- end
- printheader()
- print("")
- print("")
- print("ERROR: No Blocks in Inventory. ")
- print(" Please load any block into ")
- print(" inventory.")
- sleep(1)
- end
- end
- local function eatforward()
- -- x,y,z = gps.locate( 2, true )
- while not turtle.detectDown() do
- turtle.down()
- dy = dy - 1
- end
- while dy < 0 do
- turtle.up()
- dy = dy + 1
- turtle.select(invcheck())
- turtle.placeDown()
- end
- while turtle.detect() do
- turtle.dig()
- turtle.up()
- dy = dy + 1
- end
- while dy > 0 do
- turtle.down()
- dy = dy - 1
- end
- turtle.forward()
- print("nom")
- end
- local function checkturn()
- if curdir == 0 then
- if dir == "left" then
- curdir = 1
- turtle.turnLeft()
- eatforward()
- turtle.turnLeft()
- print("1")
- return true
- end
- if dir == "right" then
- curdir = 1
- turtle.turnRight()
- eatforward()
- turtle.turnRight()
- print("2")
- return true
- end
- end
- if curdir == 1 then
- if dir == "right" then
- curdir = 0
- turtle.turnLeft()
- eatforward()
- turtle.turnLeft()
- print("3")
- return true
- end
- if dir == "left" then
- curdir = 0
- turtle.turnRight()
- eatforward()
- turtle.turnRight()
- print("4")
- return true
- end
- end
- end
- local function eatfar()
- while ddist < dist do
- ddist = ddist + 1
- -- eaten = eaten + 1
- eatforward()
- end
- end
- local function eatall()
- while dside < side do
- eatfar()
- ddist = 0
- checkturn()
- dside = dside + 1
- end
- eatfar()
- end
- local tArgs = { ... }
- if #tArgs < 3 then
- printheader()
- print("Land Flatter for Turtles. by Dalva")
- print("")
- print("")
- print("USAGE : flatit <left/right> ")
- print(" <length> <width>")
- print("EX : flatit 10 right 5")
- print("NOTE : Do not use in areas where ")
- print(" trees are present.")
- return false
- end
- if not tArgs[1] == left and tArgs[1] == right then
- printheader()
- print("")
- print("")
- print("ERROR: Unknown Direction: " ..tArgs[1])
- print("Please input either left/right")
- print("")
- return false
- end
- dy = 0
- ddist = 0
- dside = 0
- curdir = 0
- dist = tonumber(tArgs[2])
- side = tonumber(tArgs[3])
- dir = (tArgs[1])
- printheader()
- print("")
- print("")
- print("Beginning Flattening Operation...")
- print("Length : " ..dist)
- print("Width : " ..side)
- print("Direction : " ..dir)
- print("")
- eatall()
- printheader()
- print("")
- print("")
- print("SUCCESS: Flattening Completed")
Add Comment
Please, Sign In to add comment