Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local r = require("robot")
- local c = require("component")
- local crops = 64;
- local batida = false;
- local v = 1;
- local function checkFuel()
- if c.generator.count() < 10 then
- r.select(14)
- r.place()
- os.sleep(1)
- r.select(13)
- c.inventory_controller.equip()
- r.select(15)
- for i=1,27,1 do
- if c.inventory_controller.getStackInSlot(3, i) then
- c.inventory_controller.suckFromSlot(3, i)
- c.generator.insert()
- r.select(14)
- r.swing()
- r.select(13)
- c.inventory_controller.equip()
- return true
- end
- end
- print("Acabou o estoque de carvão")
- print("Finalizando programa")
- r.select(14)
- r.swing()
- r.select(13)
- c.inventory_controller.equip()
- os.exit()
- else
- return false
- end
- end
- local function checkCrops()
- if crops >= 64 then
- r.select(10)
- r.place()
- r.select(13)
- c.inventory_controller.equip()
- for i=1,27,1 do
- if c.inventory_controller.getStackInSlot(3,i) then
- c.inventory_controller.suckFromSlot(3,i)
- r.select(10)
- r.swing()
- r.select(13)
- c.inventory_controller.equip()
- crops = 0
- return true
- end
- end
- r.select(10)
- r.swing()
- r.select(13)
- c.inventory_controller.equip()
- print("Nao há mais crops")
- print("Finalizando programa")
- os.exit()
- return false
- else
- return false
- end
- end
- local function checkTutor()
- if c.inventory_controller.getStackInInternalSlot(1) == nil then
- r.select(6)
- r.place()
- r.select(13)
- c.inventory_controller.equip()
- r.select(1)
- for i=1,27,1 do
- if c.inventory_controller.getStackInSlot(3,i) then
- c.inventory_controller.suckFromSlot(3,i)
- r.select(6)
- r.swing()
- r.select(13)
- c.inventory_controller.equip()
- return true
- end
- print("Acabou os tutores de crescimento")
- print("Finalizando programa")
- r.select(6)
- r.swing()
- r.select(13)
- c.inventory_controller.equip()
- os.exit()
- return true
- end
- else
- return false
- end
- end
- local function pathfinder()
- if r.detect() then
- batida = true
- end
- if batida == true then
- if v == 1 then
- r.turnLeft()
- if not r.forward() then
- print("Programa finalizado")
- print("Obrigado por adquirir")
- print("by HeyZeer0")
- os.exit()
- return
- end
- r.turnLeft()
- batida = false
- v = 2
- return
- else
- r.turnRight()
- if not r.forward() then
- print("Fim do programa")
- print("Obrigado por adquirir")
- print("by HeyZeer0")
- os.exit()
- return
- end
- r.turnRight()
- batida = false
- v = 1
- return
- end
- end
- r.select(1)
- r.forward()
- if not r.compareDown() then
- r.placeDown()
- r.useDown()
- crops = crops + 1
- end
- end
- if 1 == 1 then
- if not checkFuel() then
- print("Com combustivel")
- else
- print("Consumindo combustivel")
- return
- end
- if not checkTutor() then
- print("Com tutor")
- else
- print("Consumindo tutor")
- return
- end
- if not checkCrops() then
- print("Com crops")
- else
- print("Consumindo crops")
- return
- end
- pathfinder()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement