Advertisement
murlocking

Untitled

May 9th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.55 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 inventory = component.inventory_controller
  8. local g = component.generator
  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 Coal_names = {}
  23. Coal_names[1] = "minecraft:coal"
  24. Coal_names[2] = "minecraft:planks"
  25. Coal_names[3] = "minecraft:log"
  26. Coal_names[4] = "minecraft:blaze_rod"
  27. Coal_names[5] = "minecraft:lava_bucket"
  28.  
  29. local empty_bucket = {}
  30. empty_bucket[1] = "minecraft:bucket"
  31. empty_bucket[2] = "minecraft:lava_bucket"
  32.  
  33.  
  34.  
  35. local function getCoal(stack_info)
  36.   if stack_info == nil then
  37.     return false
  38.   end
  39.   for index, known_coal_name in ipairs(Coal_names) do
  40.     if stack_info.name == known_coal_name then
  41.       return true
  42.     end
  43.   end
  44.   return false
  45. end
  46.  
  47. if computer.energy() <=200 then
  48. robot.select(5) ; robot.drop() ; robot.select(16) ; robot.drop()
  49. robot.select(14) ; robot.place() ; robot.select(15)
  50. for slot=1,27 do
  51.   local stack_info = inventory.getStackInSlot(side, slot)
  52.  
  53.   --- inspect the stack_info when it is not nil
  54.   if getCoal(stack_info) then
  55.     print(stack_info.name, "found in slot", slot)
  56.     inventory.suckFromSlot(sides.front, slot)
  57.     break
  58.   end
  59. end
  60. robot.select(16) ; inventory.dropIntoSlot(side, 1) ; robot.select(5) ; robot.swing() ; robot.transferTo(14)
  61. end
  62.  
  63.  
  64. local function isFuelRemaining(stack_info)
  65.    if stack_info == nil then
  66.     return false
  67.   end
  68.   for index, known_rail_name in ipairs(Coal_names) do
  69.     if stack_info.name == known_coal_name then
  70.       return true
  71.     end
  72.   end
  73.   return false
  74. end
  75. local stack_info = inventory.getStackInInternalSlot(5)
  76.    --- inspect the stack_info when it is not nil
  77.   if isFuelRemaining(stack_info) then
  78.     g.insert()
  79.   end
  80.  
  81. local function isBucket(stack_info)
  82.   if stack_info == nil then
  83.     return false
  84.   end
  85.   for index, bucket_name in ipairs(empty_bucket) do
  86.     if stack_info.name == bucket_name then
  87.       return true
  88.     end
  89.   end
  90.   return false
  91. end
  92. robot.select(5) ; robot.drop() ; g.remove()
  93. local stack_info = inventory.getStackInInternalSlot(5)
  94.  if isBucket(stack_info) then
  95. left() ; robot.select(8) ; robot.place() ; robot.select(5) ; inventory.dropIntoSlot(side, 1) ; robot.select(8) ; robot.swing() ; right()
  96. end
  97.  isFuelRemaining(stack_info)
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104. getCoal(stack_info)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement