Guest User

Untitled

a guest
Sep 3rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.24 KB | None | 0 0
  1. local com = require("component")
  2. local side = require("sides")
  3. local ic = com.transposer
  4. local rs = com.redstone
  5. local screen = com.screen
  6. local inSlot = ic.getStackInSlot
  7. local heatedCells = {}
  8. local nullCells = {}
  9. local quantityCells = {}
  10.  
  11. local cellArray = {1,5,8,12,17,19,24,31,36,38,43,47,50,54}
  12. -- io.write( 'Хотите изменить схему? y|n \n' )
  13. -- local a = io.read()
  14. -- if a == 'y' then io.write( 'Введите через пробел номера слотов новой схемы, где будут элементы охлаждения\n' ) local s = io.read() cellArray = {} for number in string.gmatch(s, '[^%s]+') do table.insert(cellArray, number) end for k,v in pairs(cellArray) do print('['..k..']',v) end end
  15. local range = #cellArray
  16.  
  17. function checkCells()
  18.     for i = 1, range do
  19.         inSlotCache = inSlot(side.up,cellArray[i])
  20.         if inSlotCache ~= nil and (string.match(inSlotCache.label, "NaK Coolantcell") == "NaK Coolantcell" or string.match(inSlotCache.label, "He Coolantcell") == "He Coolantcell")
  21.             then
  22.                 quantityCells[i] = cellArray[i]
  23.                 if inSlotCache.damage == 99
  24.                     then
  25.                         heatedCells[i] = cellArray[i]
  26.                     else
  27.                     if heatedCells[i] == cellArray[i] then heatedCells[i] = nil end
  28.                 end
  29.             else
  30.             if inSlotCache == nil and quantityCells[i] == cellArray[i] then quantityCells[i] = nil nullCells[i] = cellArray[i] end
  31.         end
  32.     end
  33.     print(#quantityCells)
  34.     if #heatedCells == 0 and #quantityCells == range then return true else return false end
  35. end
  36.  
  37. function transferCells(heated, null)
  38.     if #heated > 0 then
  39.         for i = 1, #heated do
  40.             print( 'Transfer cell outside from ' .. heated[i] .. 'slot' )
  41.             ic.transferItem(side.up, side.south, 1, heated[i], 1)
  42.         end
  43.     end
  44.     checkCells()
  45.     for k, v in pairs( null ) do
  46.         print( k, v )
  47.     end
  48.     print(#null)
  49.     if #null > 0 then
  50.         for k in pairs(null) do
  51.             print( 'Transfer cell inside into ' .. null[k] .. ' slot' )
  52.             ic.transferItem(side.north, side.up, 1, 2, null[k])
  53.             print('ok')
  54.         end
  55.         nullCells = {}
  56.     end
  57.     greatLoop()
  58. end
  59.  
  60. function greatLoop()
  61.     while checkCells() == true do
  62.         print('true')
  63.         os.sleep(1)
  64.     end
  65.     if checkCells() == false then print('false') transferCells(heatedCells, nullCells) end
  66. end
  67. greatLoop()
Add Comment
Please, Sign In to add comment