Advertisement
Asioron

Avtovalilka

Mar 15th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. ---------------------------------------------------------
  2. --                    Программа                        --
  3. -- для сушки мяса и других вещей на досках вяления     --
  4. --     в Майнкрафт на компьютере и транспозере         --
  5. --                из мода OpenComputers                --
  6. --                   Автовялилка v0.1                  --
  7. --          проект http://computercraft.ru             --
  8. --                 2017, © Asior                       --
  9. ---------------------------------------------------------
  10. local c = require("component")
  11. local computer = require("computer")
  12.  
  13. local function sortirovka(adr, input)
  14.   local size = c.proxy(adr).getStackInSlot(1, 1)
  15.   if size and size.size <= 9 then
  16.     print('< 9')
  17.     for i=3, c.proxy(adr).getInventorySize(1) do
  18.       local info = c.proxy(adr).getStackInSlot(1, i)
  19.       print(tostring(info)..'|'..tostring(input.name))
  20.       if info and info.name == input.name then
  21.         for i1=1, 10 do
  22.           if not c.proxy(adr).transferItem(1, 1, 1, i) then
  23.             sortirovka(adr, input)
  24.             return
  25.           end
  26.         end
  27.         return
  28.       end
  29.     end
  30.   end
  31. end
  32. ------------------------------------------
  33. tr = {}
  34. for i, _ in pairs(c.list('transposer')) do
  35.   tr[#tr + 1] = i
  36. end
  37.  
  38. while true do
  39.   for i1 = 1, #tr do
  40.     local input = c.proxy(tr[i1]).getStackInSlot(1, 1)
  41.     local output = c.proxy(tr[i1]).getStackInSlot(1, 2)
  42.       for i = 2, 5 do
  43.       local name = c.proxy(tr[i1]).getStackInSlot(i, 1)
  44.       if i == 2 then sortirovka(tr[i1], input) end
  45.       if name and name.name == output.name then
  46.         print(name.name..'|1|'..output.name..'|'..i1)
  47.         c.proxy(tr[i1]).transferItem(i, 1)
  48.         c.proxy(tr[i1]).transferItem(1, i)
  49.       elseif name == nil then
  50.         c.proxy(tr[i1]).transferItem(1, i)
  51.       end
  52.     end
  53.   end
  54.   print('sleep')
  55.   os.sleep(50)
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement