Advertisement
Guest User

Untitled

a guest
May 9th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. local robot = require("robot")
  2. local computer = require("computer")
  3. local sides = require("sides")
  4. local component = require("component")
  5. local ser = require("serialization")
  6.  
  7. local c = component.crafting
  8. local inventory = component.inventory_controller
  9.  
  10.  
  11.  
  12. local left = robot.turnLeft
  13. local right = robot.turnRight
  14. local TURN = robot.turnAround
  15. local d = robot.detect
  16. local dUp = robot.detectUp
  17. local dDown = robot.detectDown
  18.  
  19. local side = sides.front
  20.  
  21. local size = ic.getInventorySize(side)
  22. if not size then return nil end
  23.  
  24.  
  25. print("inventory size: ", size)
  26.  
  27. local nRail_names = {}
  28. nRail__names[1] = "minecraft:rail"
  29. nRail__names[2] = "TConstruct:rail.wood"
  30.  
  31.  
  32. local function isRail(stack_info)
  33.   if stack_info == nil then
  34.     return false
  35.   end
  36.   for index, known_rail_name in ipairs(nRail_names) do
  37.     if stack_info.name == known_rail_name then
  38.       return true
  39.     end
  40.   end
  41.   return false
  42. end
  43.  
  44. for slot=1,size do
  45.   local stack_info = ic.getStackInSlot(side, slot)
  46.  
  47.   --- inspect the stack_info when it is not nil
  48.   if isRail(stack_info) then
  49.     print(stack_info.name, "found in slot", slot)
  50.     ic.suckFromSlot(sides.front, slot)
  51.   end
  52. end
  53.  
  54. isRail(stack_info)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement