Advertisement
ivan52

craftUran

Jan 10th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.95 KB | None | 0 0
  1. local r = require('robot')
  2. local comp = require('computer')
  3. local term = require('term')
  4. local com = require('component')
  5. local inv = require('component').inventory_controller
  6. local crafting =  require('component').crafting
  7. --========ТАБЛИЦЫ КРАФТОВ==========--
  8. uranFuel = {}
  9. uranFuel[5] = {}
  10. uranFuel[3] = {}
  11. uranFuel[5]['IC2:itemUran238'] = {kol = 6, 1,2,3,9,10,11}
  12. uranFuel[3]['IC2:itemUran235small'] = {kol = 3, 5,6,7}
  13. moxFuel = {}
  14. moxFuel[5] = {}
  15. moxFuel[3] = {}
  16. moxFuel[5]['IC2:itemUran238'] = {kol = 6, 1,2,3,9,10,11}
  17. moxFuel[3]['IC2:itemPlutonium'] = {kol = 3, 5,6,7}
  18. function rasstan(item,side)
  19.   if item[side] ~= nil then
  20.     r.select(15)
  21.     for slot = 1 , inv.getInventorySize(0) do
  22.       if inv.suckFromSlot(0,slot) then
  23.         if item[side][inv.getStackInInternalSlot(15).name] ~= nil then
  24.           if inv.getStackInInternalSlot(15).size >= item[side][inv.getStackInInternalSlot(15).name].kol then
  25.             r.select(15)
  26.             r.transferTo(4,item[side][inv.getStackInInternalSlot(15).name].kol)
  27.             r.dropDown()
  28.             r.select(4)
  29.             for i=1,item[side][inv.getStackInInternalSlot(4).name].kol do
  30.               r.transferTo(item[side][inv.getStackInInternalSlot(4).name][i],1)
  31.             end
  32.             return true
  33.           else
  34.             r.dropDown()
  35.           end
  36.         else
  37.           r.dropDown()
  38.         end
  39.       end
  40.     end
  41.     return false
  42.   else
  43.     return false
  44.   end
  45. end
  46. function sbros(side)
  47.   if side == 5 then
  48.     r.turnLeft()
  49.   end
  50.   for slot1=1, r.inventorySize() do
  51.     if r.count(slot1) > 0 then
  52.       r.select(slot1)
  53.       r.drop()
  54.     end
  55.   end    
  56.   if side == 5 then
  57.     r.turnRight()
  58.   end
  59. end
  60. function craft(item)
  61.   if item[3] ~= nil then
  62.     if not rasstan(item,3) then
  63.        return false
  64.     end
  65.   end
  66.   if item[5] ~= nil then
  67.     a = 0
  68.     while not rasstan(item,5) do
  69.       a = a + 1
  70.       if a > 5 then
  71.         for a=1,16 do
  72.           if r.count(a)>0 then
  73.             r.select(a)
  74.             r.dropDown()
  75.           end
  76.         end
  77.         return false
  78.       end
  79.     end
  80.   end
  81.   crafting.craft()
  82.   r.dropDown()
  83. end
  84. while true do
  85.   for i=1,4 do
  86.     craft(uranFuel)
  87.     craft(moxFuel)
  88.   end
  89.   i=1
  90.   r.select(15)
  91.   while inv.suckFromSlot(0,i) do
  92.     if inv.getStackInInternalSlot(15).name == 'IC2:itemPlutoniumSmall' then
  93.       if inv.getStackInInternalSlot(15).size >= 9 then
  94.         kol = inv.getStackInInternalSlot(15).size
  95.         size = kol - (kol)%9
  96.         r.transferTo(4,size)
  97.         r.dropDown()
  98.         r.select(4)
  99.         kol = r.count(4)
  100.         for i=1,11 do
  101.           if i%4 ~= 0 then
  102.             r.transferTo(i,kol/9)
  103.           end
  104.         end
  105.         os.sleep(1)
  106.         r.select(8)
  107.         os.sleep(1)
  108.         crafting.craft()
  109.         os.sleep(1)
  110.         r.dropDown()
  111.         r.select(15)
  112.       else
  113.         r.dropDown()
  114.       end
  115.     else
  116.       r.dropDown()
  117.     end
  118.     i=i+1
  119.   end
  120. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement