Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Potato Farm Code
- --
- southwest = {187, 66, 267}
- sourtheast = {195, 66, 267}
- northwest = {187, 66, 259}
- northeast = {195, 66, 259}
- fuelChest = {194, 66, 268}
- storageChest = {188, 66, 268}
- slotCount = 16
- -- Returns for 'itemName' slot in inventory
- function getItemIndex(itemName)
- for slot = 1, 16, 1 do
- item = turtle.getItemDetail(slot)
- if(item ~= nil) then
- if(item["name"] == itemName) then
- return slot
- end
- end
- end
- end
- function checkFuel()
- turtle.select(1)
- if(turtle.getFuelLevel() < 50) then
- print("Attempting Refuel...")
- for slot = 1, slotCount, 1 do
- turtle.select(slot)
- if(turtle.refuel(1)) then
- return true
- end
- end
- return false
- else
- return true
- end
- end
- function getFuel()
- end
- -- returns turtle distance compared to target location and counts fuel cost
- function getDistance(currX, currY, currZ)
- cordX, cordY, cordZ = gps.locate()
- fuelCost = turtle.getFuelLevel()
- --effeicency variable -checks if travel is possible !!change later after troubleshooting
- efficiency = true
- compX = currX -
- compared_set = {}
- return distance, efficency
- end
- -- actual command to move to a given destination
- function moveTo(x, y, z)
- destination = {x, y, z}
- if destination~=gps.locate()
- then
- -- moveing to location based on
- end
- end
- -- main fuction to have a never ending farm
- -- !!northeast is a place holder for the last block in the calculated inputs
- -- !! make sure code can move side to side in a 8x8 grid repeating the dig/plant action
- -- !! has to stay inside placed location
- while(1) do
- -- checks turtle for fuel
- if checkFuel()then
- startCord = gps.locate()
- fuelstat = turtle.getFuelLevel()
- distan, efficiency_value = getDistance()
- --checks if given inputs are possible
- if(efficiency_value) then
- isBlock, data = turtle.inspectDown()
- if(isBlock) then
- if (data['state']['age'] <= 7)
- then
- turtle.digDown()
- potatoIndex = getItemIndex("minecraft:potato")
- turtle.select(potatoIndex)
- turtle.placeDown()
- end
- else
- potatoIndex = getItemIndex("minecraft:potato")
- turtle.placeDown()
- end
- end
- -- If turtle doesnt have fuel then it moves to chest, refuels, returns, then starts program from the top
- else
- startCord = gps.locate()
- moveTo(fuelChest)
- turtle.refuel()
- if turtle.checkFuel() then
- moveTo(startCord)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement