Advertisement
Wassaa

red control

Jan 8th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.81 KB | None | 0 0
  1. local oreMot = peripheral.wrap("extractor_8")
  2. local dustMot = peripheral.wrap("extractor_9")
  3. local oreSig = "left"
  4. local dustSig = "right"
  5. local endDir = "south"
  6.  
  7. function slotTable(nr, rig)
  8. --print (rig.getStackInSlot(nr))
  9. return rig.getStackInSlot(nr)
  10. end
  11.    
  12. function getResult(mode)
  13.  
  14.     if mode == 1 then
  15.         --print("ore machine")
  16.         machine = oreMot
  17.         matSlot1 = 1
  18.         matSlot2 = 4
  19.         resSlot1 = 5
  20.         resSlot2 = 2
  21.         resSlot3 = 8
  22.         resSlot4 = 9
  23.         signal = oreSig
  24.         opDir = "north"
  25.     else
  26.         --print("dust machine")
  27.         machine = dustMot
  28.         matSlot1 = 2
  29.         matSlot2 = 3
  30.         resSlot1 = 7
  31.         resSlot2 = 4
  32.         signal = dustSig
  33.         opDir = "south"
  34.        
  35.     end
  36.     --check if machines have stuff to work with, if not take away Red
  37.     if slotTable(matSlot1, machine) == nil and slotTable(matSlot2, machine) == nil then
  38.         print (tostring(matSlot1) .. "and" .. tostring (matSlot2) .. " are empty")
  39.         rs.setOutput(signal, false)
  40.     else
  41.         rs.setOutput(signal, true)
  42.     end
  43.        
  44.     --first result material (dust/solution) gets moved
  45.     if slotTable(resSlot1, machine) ~= nil then
  46.         machine.pushItemIntoSlot(opDir, resSlot1, 64, resSlot1 - 3)
  47.     end
  48.     --move more sutff
  49.     if slotTable(resSlot2, machine) ~= nil then
  50.         machine.pushItemIntoSlot(opDir, resSlot2, 64, resSlot2)
  51.     end
  52.    
  53.     if machine == oreMot then
  54.         if slotTable(resSlot3, machine) ~= nil then
  55.             --print ("pushing")
  56.             machine.pushItem(endDir, resSlot3, 64)
  57.         --else
  58.             --print("done")
  59.         elseif slotTable(resSlot4, machine) ~= nil then
  60.             machine.pushItem(endDir, resSlot4, 64)
  61.         end
  62.     end
  63. end
  64.  
  65. while true do
  66. getResult(1)
  67. getResult(2)
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement