Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 0
- z = 0
- a = 8
- b = 8
- isRunning = true
- isLeft = true
- isFinishCycle = false
- cycle = 0;
- function statsTurtle()
- term.setCursorPos(1,12)
- print("Ciclos: ", math.floor(cycle / 2))
- term.setCursorPos(1,13)
- actualFuel = turtle.getFuelLevel()
- totalFuel = turtle.getFuelLimit()
- print("Energia: ",actualFuel,"/",totalFuel)
- end
- function turnRight()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- function turnLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- function transferItemsToChest()
- for i = 2,16 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(1)
- end
- function harvestCrop(crop)
- if crop.state.age == 7 then
- turtle.digDown()
- turtle.placeDown()
- end
- end
- function placeCrop()
- turtle.placeDown()
- end
- function checkBlockDown()
- isBlock,block = turtle.inspectDown();
- chest = nil
- crop = nil
- if isBlock then
- if type(block) == "table" then
- chest = string.find(block.name,"chest")
- crop = string.find(block.name,"crop")
- end
- else
- placeCrop()
- end
- if chest ~= nil then
- term.clear()
- term.setCursorPos(1,6)
- print("Limpiando inventario...")
- statsTurtle()
- transferItemsToChest()
- else
- if crop ~= nil then
- term.clear()
- term.setCursorPos(1,6)
- print("Crop Actual: ",block.state.age)
- statsTurtle()
- harvestCrop(block)
- end
- end
- end
- function checkCropHarvested()
- turtle.forward()
- turtle.down()
- turtle.turnLeft()
- turtle.turnLeft()
- while true do
- isBlock,block = turtle.inspect()
- if isBlock then
- sleep(1)
- term.clear()
- term.setCursorPos(1,6)
- print("Nivel del Crop: ", block.state.age)
- statsTurtle()
- if block.state.age == 7 then
- turtle.up()
- turtle.forward()
- break
- end
- else
- turtle.up()
- turtle.forward()
- break
- end
- end
- end
- while isRunning do
- checkBlockDown()
- if x == a and z == b then
- isFinishCycle = true
- end
- if x == a then
- if isFinishCycle then
- isFinishCycle = false
- isLeft = not isLeft
- z = 0
- checkCropHarvested()
- cycle = cycle + 1;
- else
- if isLeft then
- turnRight()
- else
- turnLeft()
- end
- z = z + 1
- end
- isLeft = not isLeft
- x = 0
- else
- turtle.dig()
- turtle.forward()
- x = x + 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement