Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- [[ Defaults ]] --
- width=9
- length=9
- channel=-1
- plant="true"
- fuelId="minecraft:coal"
- sleepTime=120
- borderSlot=14
- seedSlot=15
- fuelSlot=16
- -- [[ END Defaults ]] --
- -- [[ Variables ]] --
- offsetX=0
- offsetZ=1
- chest= "minecraft:chest"
- -- [[ END Variables ]] --
- local function checkBlock(compareFrom, compareTo)
- if (compareFrom == compareTo) then
- return true
- end
- end
- --print(detectChest("up")) -- Test function
- function detectChest(direction)
- local found=false
- if (direction == "up") then
- blockDetected,blockDetails = turtle.inspectUp()
- elseif (direction == "front") then
- blockDetected,blockDetails = turtle.inspect()
- elseif (direction == "down") then
- blockDetected,blockDetails = turtle.inspectDown()
- end
- if (blockDetected) then
- name=blockDetails['name']
- if (name == chest) then
- return true
- end
- end
- return false
- end
- local function harvestCrop()
- blockDetected,blockDetails = turtle.inspectDown()
- --print(blockDetected)
- if (blockDetected) then
- blockName=blockDetails['name']
- --print(blockName)
- if(blockName=='minecraft:wheat' or blockName=='minecraft:carrot' or blockName=='minecraft:potato') then
- blockAge=blockDetails['state']['age']
- if( blockAge == 7) then
- turtle.digDown()
- end
- end
- end
- end
- local function loadFuel ()
- if (detectFuelChest()) then
- currentFuel=turtle.getFuelLevel()
- maxFuel=turtle.getFuelLimit()
- fuelPercent=(math.floor((currentFuel/maxFuel)*100))
- if (int(fuelPercent) < 10 ) then
- if(turtle.suckUp()) then
- end
- end
- end
- end
- local function checkSide(direction)
- end
- function saveTable(table,name)
- local file = fs.open(name,"w")
- file.write(textutils.serialize(table))
- file.close()
- end
- function countBorderSlot()
- end
- local function main()
- while true do
- -- Start
- -- Check Setup
- -- Check for Chest Above to Refuel
- if(detectChest("up") ~= true) then
- print("Fuel Chest Not Found.")
- print("Please place a chest above the bot.")
- break
- end
- -- Check for Chest In Front to Get Seed
- if(detectChest("front") ~= true) then
- print("Seed Chest Not Found.")
- print("Please place a chest in front the bot (outside the farm area).")
- break
- end
- -- Check for Chest Below for materials
- if(detectChest("up") ~= true) then
- print("Harvest Chest Not Found.")
- print("Please place a chest below the bot.")
- break
- end
- -- Check for Item in Border Slot
- if (turtle.getItemCount(borderSlot) == 0) then
- print("Please place 1 border item in slot " .. tostring(borderSlot))
- break
- elseif (turtle.getItemCount(borderSlot) > 1) then
- print("Please only place 1 border item in slot " .. tostring(borderSlot))
- break
- end
- -- Check fuel level and refuel
- -- Check seed level and reload
- -- Check slots 1 to 13
- -- If not seed, put in chest below
- -- if seed, put in front chest
- -- Sleep for a sleepTime
- print("Sleeping for " .. tostring(sleepTime) .. " seconds.")
- sleep(sleepTime)
- print("Starting...")
- print("Finished...")
- -- Turn right
- -- Turn right
- -- until border
- -- go forward
- -- increment x
- -- then turn right, go forward, turn right
- -- repeat until border
- -- go home
- end
- end
- main()
Add Comment
Please, Sign In to add comment