Advertisement
Georggi

OreProcessing

Jun 14th, 2016
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.46 KB | None | 0 0
  1. local robot = component.proxy(component.list("robot"){})
  2. local inv = component.proxy(component.list("inventory_controller"){})
  3. function wash()
  4.     robot.turnLeft()
  5.     robot.drop()
  6.     robot.turnRight()
  7. end
  8. function heat()
  9.     robot.turnRight()
  10.     robot.drop()
  11.     robot.turnLeft()
  12. end
  13. function macerate()
  14.     robot.drop()
  15. end
  16. function intoAE()
  17.     robot.up()
  18.     robot.turnLeft()
  19.     robot.drop()
  20.     robot.turnRight()
  21.     robot.down()
  22. end
  23. function getOre()
  24.     robot.up()
  25.     robot.turnLeft()
  26.     robot.suck()
  27.     robot.turnRight()
  28.     robot.down()
  29.     print("check3");
  30.     if inv.getStackInInternalSlot().name == "Oilsands Ore" then
  31.         OilSand()
  32.     else
  33.         macerate()
  34.     end
  35. end
  36. function getProccesing()
  37.     robot.suckDown()
  38.     evaluateItem()
  39. end
  40. function OilSand()
  41.     robot.up()
  42.     robot.turnAround()
  43.     robot.drop()
  44.     robot.turnAround()
  45.     robot.down()
  46. end
  47. function SecondMacerate()
  48.     robot.turnAround()
  49.     robot.drop()
  50.     robot.turnAround()
  51. end
  52. function evaluateItem()
  53.     local t = {}
  54.     local s = inv.getStackInInternalSlot().name
  55.     print("check1");
  56.     for k, v in string.gmatch(s, "%s") do
  57.         print("check2");
  58.         t[k] = v
  59.     end
  60.     if t[0] == "Centrifuged" then
  61.         SecondMacerate()
  62.     elseif t[0] == "Purified" then
  63.         heat()
  64.     elseif t[0] == "Crushed" then
  65.         wash()
  66.     else
  67.         intoAE()
  68.     end
  69. end
  70. function check(side)
  71.     local p = 1
  72.     local SlotsOccupied = 0
  73.     local InventorySize = 0
  74.     local AreSlotsOccupied = false
  75.     if side == 3 then
  76.         InventorySize = macerate1Size
  77.     elseif side == 5 then
  78.         InventorySize = WashSize
  79.     elseif side == 4 then
  80.         InventorySize = HeatSize
  81.     elseif side == 2 then
  82.         InventorySize = macerate2Size
  83.     elseif side == 0 then
  84.         InventorySize = TempStorageSize
  85.     end
  86.     while InventorySize >= p do
  87.         if inv.getStackInSlot(side, p) ~= nil then
  88.             SlotsOccupied = SlotsOccupied + 1;
  89.         end
  90.         p = p + 1
  91.     end
  92.     if SlotsOccupied > 0 then
  93.         AreSlotsOccupied = true
  94.     elseif SlotsOccupied == 0 then
  95.         AreSlotsOccupied = false
  96.     end
  97.     return AreSlotsOccupied
  98. end
  99. local macerate1Size = inv.getInventorySize(3)
  100. local WashSize = inv.getInventorySize(5)
  101. local HeatSize = inv.getInventorySize(4)
  102. local macerate2Size = inv.getInventorySize(2)
  103. local TempStorageSize = inv.getInventorySize(0)
  104. robot.up()
  105. local OreStorageSize = inv.getInventorySize(4)
  106. local OilSandSize = inv.getInventorySize(2)
  107. robot.down()
  108.  
  109. while true do
  110.     while check(0) == true do
  111.         getProccesing()
  112.         while check(5) == true or check(3) == true or check(4) == true or check(3) == true do
  113.             os.sleep(2)
  114.         end
  115.     end
  116.     getOre()
  117. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement