SHARE
TWEET

Untitled

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