Advertisement
FluttyProger

FarmCoal.lua

May 3rd, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local robot = require("robot")
  2. local com = require("component")
  3. local e = require("event")
  4. local co = require("computer")
  5. local inv = com.inventory_controller
  6. local inv_size = robot.inventorySize()
  7. local geo = com.geolyzer
  8. local sob = com.tractor_beam.suck
  9. local trse,da = true,true
  10.  
  11. local function spusk()
  12.   da=false
  13.   local tek=robot.select()
  14.   for i=7, inv_size do
  15.     local s = inv.getStackInInternalSlot(i)
  16.     if s ~= nil then
  17.       if s.name == "minecraft:log" or s.name == "minecraft:coal" or s.name == "minecraft:sapling" or s.name == "minecraft:apple" then
  18.         robot.select(i)
  19.         robot.dropDown()
  20.       --elseif s.name == "Forestry:sapling" then
  21.       --  robot.select(i)
  22.       --  robot.dropUp()
  23.       end
  24.     end
  25.   end
  26.   robot.select(tek)
  27.   da=true
  28. end
  29.  
  30. local tim = e.timer(60*4,spusk,math.huge)
  31.  
  32. local function inv_scaner(filter)
  33.   for i=1, inv_size do
  34.     if inv.getStackInInternalSlot(i) ~= nil then
  35.       if inv.getStackInInternalSlot(i).name == filter then
  36.         return i
  37.       end
  38.     end
  39.   end
  40.   return 0
  41. end
  42.  
  43. local function pitanie()
  44.   da=false
  45.   local tek=robot.select()
  46.   if co.energy() <= 10000 then
  47.     local pe=inv_scaner("minecraft:coal")
  48.     if pe ~= 0 then
  49.       local size = inv.getStackInInternalSlot(pe).size
  50.       robot.select(pe)
  51.       com.generator.insert(size-1)
  52.     end
  53.   end
  54.   robot.select(tek)
  55.   da=true
  56. end
  57.  
  58. local pit=e.timer(60*2,pitanie,math.huge)
  59.  
  60. local function inv_scaner2()
  61.   robot.turnAround()
  62.   for i=1, inv_size do
  63.     if inv.getStackInSlot(3,i) ~= nil then
  64.       if inv.getStackInSlot(3,i).name == "Forestry:fertilizerCompound" then
  65.         return i
  66.       end
  67.     end
  68.   end
  69.   return 0
  70. end
  71.  
  72. while true do
  73.   if da then
  74.     local udo = inv_scaner("Forestry:fertilizerCompound")
  75.     if geo.analyze(3).name=="minecraft:air" then
  76.       local sl = inv_scaner("Forestry:sapling")
  77.       if sl ~= 0 then
  78.         robot.select(sl)
  79.         robot.place()
  80.       else
  81.         print("Где саплинги??? у тебя есть 3 секунды, а то я...")
  82.         os.sleep(3)
  83.       end
  84.     else
  85.       if udo ~= 0 then
  86.         robot.select(udo)
  87.         repeat
  88.           trse=robot.place()
  89.           os.sleep(0.1)
  90.         until trse == false or trse == nil
  91.       else
  92.         local udob = inv_scaner2()
  93.         if udob ~= 0 then
  94.           inv.suckFromSlot(3,udob)
  95.           robot.turnAround()
  96.         else
  97.           print("Где удобрение??? у тебя есть 3 секунды, а то я...")
  98.         end
  99.         os.sleep(3)
  100.       end
  101.       if not trse then
  102.         robot.swing()
  103.         os.sleep(2)
  104.         repeat
  105.           trse=sob()
  106.         until trse==false
  107.       end
  108.     end
  109.   end
  110.   os.sleep()
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement