Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("/egps.lua")
- egps.startGPS()
- egps.setLocationFromGPS()
- function get_hive(h)
- check_fuel()
- goto_location(h)
- process_hive()
- dropoff_stuff()
- end
- function dropoff_stuff()
- goto_location(dropoff)
- if sanity_check() == false then
- print("Error at dropoff chest")
- error()
- end
- for i = 1,15 do
- turtle.select(i)
- if turtle.getItemCount(i) then
- turtle.drop()
- end
- end
- goto_location(fuel)
- end
- function process_hive()
- local b = true
- local count = 0
- turtle.select(1)
- repeat
- b = turtle.suck()
- if b then count = count + 1
- end
- until b == false
- for i = 1,count do
- turtle.select(i)
- local data = turtle.getItemDetail(i)
- if string.find(data.name, "princess") then
- turtle.drop()
- elseif string.find(data.name, "drone") then
- turtle.drop(1)
- end
- end
- end
- function check_fuel()
- if goto_location(fuel) == false then
- print("Unable to move to fuel dump.")
- error()
- end
- if sanity_check() == false then
- print("Unable to confirm at fuel dump.")
- error()
- end
- if turtle.getItemCount(16) < 20 then
- turtle.select(16)
- turtle.suck(20)
- end
- if turtle.getFuelLevel() < 1000 then
- turtle.select(16)
- turtle.refuel(20)
- end
- end
- function goto_location(d)
- -- print(d[1], d[2], d[3], d[4])
- egps.moveTo(d[1],d[2],d[3],d[4])
- end
- function sanity_check()
- local success,data = turtle.inspect()
- if success then
- if string.find(data.name, "apiary") then
- return true
- elseif string.find(data.name, "alveary") then
- return true
- elseif string.find(data.name, "iron_chest") then
- return true
- end
- end
- return false
- end
- -- Hive definitions
- --
- -- Directions:
- -- North = 0
- -- West = 1
- -- South = 2
- -- East = 3
- --
- -- Fourth entry for each is direction
- dropoff={127,64,341,1}
- fuel={127,64,345,1}
- alv1={130,64,343,3}
- hive1={133,64,347,2}
- hive2={138,64,347,2}
- hive3={143,64,351,3}
- hive4={143,64,355,2}
- hive5={134,64,358,1}
- hive6={120,64,357,2}
- danger={158,65,395,3}
- --------------------------------
- -- Main program
- --------------------------------
- while true do
- get_hive(alv1)
- get_hive(hive1)
- get_hive(hive2)
- get_hive(hive3)
- get_hive(hive4)
- get_hive(hive5)
- get_hive(hive6)
- get_hive(danger)
- sleep(60)
- end --while
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement