Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 'flat' for turtles
- -- Made by ryanv09 (modified by TeoremaPi)
- -- Place the turtle at southwest corner of desired surface
- arg = {...}
- length = arg[1]
- width = arg[2]
- -- This is the slot that is checked for blocks
- slots = 1
- -- This is the slot that is checked for fuel
- fuel = 16
- -- Usage
- if (length == nil or width == nil) then
- print ("Usage: flat <length> <width>")
- return
- end
- -- Checks if the turtle is empty
- -- If empty, pauses turtle until last slot has resources
- function empty()
- if (turtle.getItemCount(slots) == 0) then
- for slot = 1, slots + 1, 1 do
- if (turtle.getItemCount(slot) ~= 0 and slot < fuel) then
- slots = slot
- turtle.select(slots)
- break
- end
- end
- if (turtle.getItemCount(slots) == 0) then
- slots = 1
- print(string.format("I am empty. Please load more materials in slot %d to continue.", slots))
- end
- while (turtle.getItemCount(slots) == 0) do
- sleep(1)
- end
- end
- if (turtle.getFuelLevel()<10) then
- if (turtle.getItemCount(fuel) == 0) then
- print(string.format("I am empty. Please load more fuel in slot %d to continue.", fuel))
- while (turtle.getItemCount(fuel) == 0) do
- sleep(1)
- end
- end
- turtle.select(fuel)
- turtle.refuel()
- turtle.select(slots)
- end
- end
- function go()
- while not turtle.forward() do
- turtle.dig()
- end
- end
- for i=0,(width - 1),1 do
- for j=1,(length - 1),1 do
- empty()
- go()
- turtle.placeDown()
- end
- if (i % 2 == 0) then
- if (i ~= width - 1) then
- turtle.turnRight()
- go()
- turtle.turnRight()
- empty()
- turtle.placeDown()
- end
- else
- if (i ~= width - 1) then
- turtle.turnLeft()
- go()
- turtle.turnLeft()
- empty()
- turtle.placeDown()
- end
- end
- if (j ~= length - 1) then
- empty()
- turtle.placeDown()
- end
- end
- print("\nSurface complete.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement