Advertisement
Guest User

farm.lua

a guest
May 26th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.94 KB | None | 0 0
  1. local r = require("robot")
  2. local c = require("component")
  3.  
  4. local crops = 64;
  5.  
  6. local batida = false;
  7. local v = 1;
  8.  
  9. local function checkFuel()
  10.  if c.generator.count() < 10 then
  11.    r.select(14)
  12.    r.place()
  13.    os.sleep(1)
  14.    r.select(13)
  15.    c.inventory_controller.equip()
  16.    r.select(15)
  17.    for i=1,27,1 do
  18.      if c.inventory_controller.getStackInSlot(3, i) then
  19.        c.inventory_controller.suckFromSlot(3, i)
  20.        c.generator.insert()
  21.        r.select(14)
  22.        r.swing()
  23.        r.select(13)
  24.        c.inventory_controller.equip()
  25.        return true
  26.      end
  27.    end
  28.    print("Acabou o estoque de carvão")
  29.    print("Finalizando programa")
  30.    r.select(14)
  31.    r.swing()
  32.    r.select(13)
  33.    c.inventory_controller.equip()
  34.    os.exit()
  35.  else
  36.    return false
  37.  end
  38. end
  39.  
  40. local function checkCrops()
  41.   if crops >= 64 then
  42.     r.select(10)
  43.     r.place()
  44.     r.select(13)
  45.     c.inventory_controller.equip()
  46.     for i=1,27,1 do
  47.      if c.inventory_controller.getStackInSlot(3,i) then
  48.       c.inventory_controller.suckFromSlot(3,i)
  49.       r.select(10)
  50.       r.swing()
  51.       r.select(13)
  52.       c.inventory_controller.equip()
  53.       crops = 0
  54.       return true
  55.      end
  56.     end
  57.    r.select(10)
  58.    r.swing()
  59.    r.select(13)
  60.    c.inventory_controller.equip()
  61.    print("Nao há mais crops")
  62.    print("Finalizando programa")
  63.    os.exit()
  64.    return false
  65.   else
  66.    return false
  67.   end
  68. end
  69.  
  70. local function checkTutor()
  71.  if c.inventory_controller.getStackInInternalSlot(1) == nil then
  72.   r.select(6)
  73.   r.place()
  74.   r.select(13)
  75.   c.inventory_controller.equip()
  76.   r.select(1)
  77.   for i=1,27,1 do
  78.    if c.inventory_controller.getStackInSlot(3,i) then
  79.      c.inventory_controller.suckFromSlot(3,i)
  80.      r.select(6)
  81.      r.swing()
  82.      r.select(13)
  83.      c.inventory_controller.equip()
  84.     return true
  85.    end
  86.    print("Acabou os tutores de crescimento")
  87.    print("Finalizando programa")
  88.    r.select(6)
  89.    r.swing()
  90.    r.select(13)
  91.    c.inventory_controller.equip()
  92.    os.exit()
  93.    return true
  94.   end
  95.  else
  96.   return false
  97.  end
  98. end
  99.  
  100. local function pathfinder()
  101.  if r.detect() then
  102.   batida = true
  103.  end
  104.  
  105.  if batida == true then
  106.   if v == 1 then
  107.    r.turnLeft()
  108.    if not r.forward() then
  109.     print("Programa finalizado")
  110.     print("Obrigado por adquirir")
  111.     print("by HeyZeer0")
  112.     os.exit()
  113.     return
  114.    end
  115.    r.turnLeft()
  116.    batida = false
  117.    v = 2
  118.    return
  119.   else
  120.    r.turnRight()
  121.    if not r.forward() then
  122.     print("Fim do programa")
  123.     print("Obrigado por adquirir")
  124.     print("by HeyZeer0")
  125.     os.exit()
  126.     return
  127.    end
  128.    r.turnRight()
  129.    batida = false
  130.    v = 1
  131.    return
  132.   end
  133.  end
  134.  
  135.  r.select(1)
  136.  r.forward()
  137.  if not r.compareDown() then
  138.   r.placeDown()
  139.   r.useDown()
  140.   crops = crops + 1
  141.  end
  142. end
  143.  
  144. if 1 == 1 then
  145.  if not checkFuel() then
  146.   print("Com combustivel")
  147.  else
  148.   print("Consumindo combustivel")
  149.   return
  150.  end
  151.  if not checkTutor() then
  152.   print("Com tutor")
  153.  else
  154.   print("Consumindo tutor")
  155.   return
  156.  end
  157.  if not checkCrops() then
  158.   print("Com crops")
  159.  else
  160.   print("Consumindo crops")
  161.   return
  162.  end
  163.  
  164.  pathfinder()
  165. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement