Advertisement
Invo_Ker

cr

Jul 20th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.72 KB | None | 0 0
  1. local drop = 1 --0 = под роботом 1 = над роботом;
  2.                --сторона дропа
  3. local NPNPNP = 3 --0 под роботом 1 над роботом 2 сзади робота 3 впереди робота 4 справа робота 5 слева робота
  4.                  -- сторона сканирования
  5. local component = require("component")
  6. local c = component.crafting
  7. local ic = component.inventory_controller
  8. local r = require("robot")
  9.  
  10. numslot = ic.getInventorySize(NPNPNP)
  11. hotslotchest = 0
  12. if numslot == nil then
  13.     print("Сундук над роботом не найден!")
  14. else
  15.     print("Всего слотов в сундуке:"..numslot)
  16. end
  17. if(ic.getStackInSlot(NPNPNP,1) ~= nil) then
  18.     if(ic.getStackInSlot(NPNPNP,1)["label"] == "Diamond Hoe") then
  19.         print("Путь:"..os.getenv("PWD"))
  20.         file = io.open(os.getenv("PWD") .."/curentcraft.txt","w")
  21.         for j = 2, 10 do
  22.             if ic.getStackInSlot(NPNPNP,j) == nil then
  23.                 item = "<empty>"
  24.             else
  25.                 item = ic.getStackInSlot(NPNPNP,j)["label"]
  26.             end
  27.             file:write(item.."\n")
  28.         end
  29.         file:close()
  30.         print("Крафт успешно записан!")
  31.         os.exit()
  32.     end
  33. end
  34. file = io.open(os.getenv("PWD") .."/curentcraft.txt","r")
  35. if file == nil then
  36.     print("Файл крафта не найден!")
  37.     os.exit()
  38. end
  39. local arr = {}
  40. for line in file:lines() do
  41.     table.insert (arr, line);
  42. end
  43. file:close()
  44. setkacrafta = {1,2,3,5,6,7,9,10,11}
  45. itemforcraft = {arr[1], arr[2], arr[3],arr[4],arr[5],arr[6],arr[7],arr[8],arr[9]}
  46. r.select(4)
  47.  
  48. local function craftthis(counts)
  49.     i = 0
  50.     while i < counts do
  51.         c.craft(64)
  52.         r.drop(drop)
  53.         i = i + 1
  54.     end
  55. end
  56.  
  57. function loadItem(robotslot, chestslot)
  58.     if chestslot == 0 then
  59.         print("В сундуке не найден нужный предмет!")
  60.         unloadallitem()
  61.     else
  62.         ic.suckFromSlot(NPNPNP,chestslot,64)
  63.         r.transferTo(robotslot,64)
  64.     end
  65. end
  66.  
  67. function unloadallitem()
  68. for j = 1, 16 do
  69. r.select(j)
  70. r.drop(drop)
  71. end
  72. r.select(4)
  73. end
  74.  
  75. function finditem(nameitem)
  76. onlyfirst = 0
  77. Cnumslot = numslot
  78. i = hotslotchest
  79. ::startfind::
  80. while i < Cnumslot do
  81. i = i + 1
  82. ItemStack = ic.getStackInSlot(NPNPNP,i)
  83.  if ItemStack ~= nil then
  84.  if ic.getStackInSlot(NPNPNP,i)["label"] == nameitem then
  85.  hotslotchest = i
  86.  return i
  87.  end
  88.  end
  89. end
  90. i = 0
  91. Cnumslot = hotslotchest
  92. onlyfirst = onlyfirst + 1
  93. if onlyfirst == 1 then goto startfind end
  94. return 0
  95. end
  96.  
  97. while true do
  98. craftthis(1)
  99.     for j = 1, 9 do
  100.         if itemforcraft[j] ~= "<empty>" then
  101.             if r.count(setkacrafta[j]) < 1 then
  102.                 print("Кончилось "..itemforcraft[j].." в слоте "..setkacrafta[j].."...")
  103.                 loadItem(setkacrafta[j],finditem(itemforcraft[j]))
  104.             end
  105.         end
  106.     end
  107. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement