Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = { ... }
- local mode = args[1]
- local width = args[2]
- local height = args[3]
- function checkInventory(mode, width, height)
- if not mode or not width or not height then
- print("Wrong parameters!")
- return false
- elseif mode == "dirt" then
- print(mode.." "..width.."x"..height)
- for i = 1, 4 do
- if not ((turtle.getItemCount(i) + turtle.getItemCount(i+4)) == (width*height)-1) then
- print("Fill 1-4 with 4x64 dirt and fill 5-8 with 16 dirt each")
- return false
- end
- end
- return true
- elseif mode == "farm" then
- else
- print("What mode? "..mode.." wtf? ")
- return false
- end
- end
- function selectedSlot()
- return turtle.getSelectedSlot()
- end
- function ItemCount(x)
- return turtle.getItemCount(x)
- end
- function selectSlot(x)
- return turtle.select(x)
- end
- function getSlotNr()
- selectSlot(1)
- for i = 1, 4 do
- if ItemCount(selectedSlot()) > 0 then
- return i
- elseif ItemCount(selectedSlot()+4) > 0 then
- return i+4
- else
- assert(false,"Error, no items!")
- end
- end
- return 0
- end
- function up()
- return turtle.up()
- end
- function destroy()
- return turtle.digDown()
- end
- function plant()
- return turtle.placeDown()
- end
- function forward(x)
- if not x then turtle.forward()
- else
- for i = 1, x do
- turtle.forward()
- end
- end
- end
- function turnLeft(x)
- return turtle.turnLeft(x)
- end
- function turnRight(x)
- return turtle.turnRight()
- end
- function changeLine(linenr)
- if ((linenr % 2) > 0) then
- --forward()
- --destroy()
- --plant()
- turnRight()
- forward()
- --destroy()
- --plant()
- turnRight()
- elseif ((linenr % 2) == 0) then
- --forward()
- --destroy()
- --plant()
- turnLeft()
- forward()
- --destroy()
- --plant()
- turnLeft()
- else
- print("fatal error")
- end
- end
- function start(mode, width, height)
- if not mode or not width or not height then
- print("Wrong parameters!")
- return false
- end
- if mode == "dirt" then
- up()
- forward()
- selectSlot(1)
- for w = 1, width do
- for h = 1, height do
- print("Schritt "..w.."/"..h)
- assert(selectSlot(getSlotNr()),"Error")
- destroy()
- plant()
- if h == height then
- changeLine(w)
- else
- print("else...")
- forward()
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement