Advertisement
Hikooshi

sh

Aug 26th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.65 KB | None | 0 0
  1. local component = require("component")
  2. local gpu = component.gpu
  3. local transposer = component.transposer
  4. local intf = component.me_interface
  5. local event = require("event")
  6. local sides = require("sides")
  7.  
  8.  
  9.  
  10. local transposers = {}
  11. local logic = "north"
  12. local silicon = "south"
  13. local eng = "east"
  14. local calc = "west"
  15. local intfConfig = {eng={},logic={},calc={},silicon={},redstone={}}
  16. local materials = {[10]={"calc",1}, [5]={"silicon", 1}, [16]={"calc", 2}, [17]={"eng",2}, [18]={"logic", 2}, [20]={"silicon", 2}, ["minecraft:diamond"]={"eng",1}, ["minecraft:gold_ingot"]={"logic",1}, ["minecraft:redstone"]={"redstone",1}}
  17. local ntc = {eng=0,logic=1,calc=0,total=1}
  18.  
  19. for k,v in component.list("transposer") do
  20. local invName = component.invoke(k, "getInventoryName", 1)
  21.   if invName == "appliedenergistics2:interface" then
  22.   transposers.main=k
  23.   elseif invName == "minecraft:chest" then
  24.   transposers.addMain={k}
  25.     for i = 2, 5 do local invName1=component.invoke(transposers.addMain[1], "getInventoryName", i) if invName1 == "appliedenergistics2:inscriber" then transposers.addMain[2] = i end end
  26.   elseif invName == "appliedenergistics2:inscriber" then
  27.   transposers.addBottom={k}
  28.     for i = 2, 5 do local invName1=component.invoke(transposers.addBottom[1], "getInventoryName", i) if invName1 == "appliedenergistics2:interface" then transposers.addBottom[2] = i end end
  29.   elseif invName == nil then
  30.   transposers.addTop={k}
  31.     for i = 2, 5 do local invName1=component.invoke(transposers.addTop[1], "getInventoryName", i) if invName1 == "minecraft:chest" then transposers.addTop[2] = i end end
  32.   end
  33. end
  34.  
  35. for i = 1, 9 do
  36. local slotName = intf.getInterfaceConfiguration(i)
  37.   if slotName.name == "appliedenergistics2:material" then
  38.     intfConfig[materials[slotName.damage][1]][materials[slotName.damage][2]] = i
  39.   else
  40.     intfConfig[materials[slotName.name][1]][materials[slotName.name][2]] = i
  41.       if slotName.name == "minecraft:redstone" then intfConfig.redstone[2] = slotName end
  42.   end
  43. end
  44. --for k,v in pairs(intfConfig) do print(k,v) print(k, intfConfig[k][1], intfConfig[k][2]) end
  45.  
  46. function craftProcessor(processor, count)
  47.  
  48. local main,full,mainCnt,fullCnt,processor,slcn = false, false, 0, 0, "", false
  49. while ntc.total > 0 do
  50. if not component.invoke(transposers.addBottom[1], "getStackInSlot", transposers.addBottom[2], intfConfig.silicon[2]) then
  51. slcn = false
  52.   if component.invoke(transposers.main, "transferItem", sides.top, sides[silicon], 1, intfConfig.silicon[1], 1) == 0 then
  53.   print("Недостаточно кремния")
  54.   else
  55.   mainCnt = mainCnt + 1
  56.   end
  57. else
  58. slcn = true
  59. end
  60. for k,v in pairs(ntc) do
  61.   if v>0 and k ~= "total" then
  62.     if not component.invoke(transposers.addMain[1], "getStackInSlot", sides.bottom, intfConfig[k][2]) then
  63.       if component.invoke(transposers.main, "transferItem", sides.top, sides[logic], 1, intfConfig[k][1], 1) == 0 then
  64.       print("Для процессора "..k.." недостаточно материалов")
  65.       else
  66.       mainCnt = mainCnt + 1
  67.       end
  68.     else
  69.         if processor == "" then processor = k end
  70.     end
  71.   end
  72. end
  73. print(processor)
  74.  
  75.           if slcn and processor ~= "" then
  76.             if not component.invoke(transposers.addMain[1], "getStackInSlot", sides.bottom, intfConfig.redstone[1]) then
  77.             print("Недостаточно редстоуна")
  78.             else
  79.             full = true
  80.             fullCnt = 0
  81.             component.invoke(transposers.addMain[1], "transferItem", 0, 1, 1, intfConfig[processor][2], 1)
  82.             component.invoke(transposers.addTop[1], "transferItem", transposers.addTop[2], 0, 1, 1, 1)
  83.             component.invoke(transposers.addBottom[1], "transferItem", transposers.addBottom[2], 1, 1, intfConfig.silicon[2], 1)
  84.             component.invoke(transposers.addMain[1], "transferItem", sides.bottom, transposers.addMain[2], 1, intfConfig.redstone[1], 1)
  85.             end
  86.           end
  87.  
  88.           while true do
  89.             if mainCnt > 0 then
  90.               repeat
  91.                 for l = 2, 5 do
  92.                 mainCnt = mainCnt - component.invoke(transposers.main, "transferItem", l, 1, 1, 2)
  93.                 end
  94.               until
  95.                 mainCnt == 0
  96.             end
  97.               if full then
  98.                 repeat fullCnt = component.invoke(transposers.addMain[1], "transferItem", transposers.addMain[2], 0, 1, 2) until fullCnt == 1
  99.               full = false
  100.               ntc.total = ntc.total - 1
  101.               ntc[processor] = ntc[processor] - 1
  102.               processor = ""
  103.               end
  104.                 if not full then break end
  105.           end
  106. print(ntc.total)
  107. end
  108.  
  109. end
  110. craftProcessor()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement