Advertisement
murlocking

Untitled

May 9th, 2020
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 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.  
  22. local nRail_names = {}
  23. nRail_names[1] = "minecraft:rail"
  24. nRail_names[2] = "TConstruct:rail.wood"
  25.  
  26.  
  27. local function getRail(stack_info)
  28.   if stack_info == nil then
  29.     return false
  30.   end
  31.   for index, known_rail_name in ipairs(nRail_names) do
  32.     if stack_info.name == known_rail_name then
  33.       return true
  34.     end
  35.   end
  36.   return false
  37. end
  38.  
  39. if robot.count(4) <=2 then
  40. robot.select(14) ; robot.place() ; robot.select(4)
  41. for slot=1,27 do
  42.   local stack_info = inventory.getStackInSlot(side, slot)
  43.  
  44.   --- inspect the stack_info when it is not nil
  45.   if getRail(stack_info) then
  46.     print(stack_info.name, "found in slot", slot)
  47.     inventory.suckFromSlot(sides.front, slot)
  48.     break
  49.   end
  50. end
  51. robot.select(5) ; inventory.dropIntoSlot(side, 1) ; robot.swing() ; robot.transferTo(14)
  52. end
  53.  
  54. getRail(stack_info)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement