Advertisement
Guest User

getCoal3.lua

a guest
May 9th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 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. local stack_info = 0
  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 fuel_names = { ["minecraft:coal"] = true, ["minecraft:planks"] = true, ["minecraft:log"] = true, ["minecraft:blaze_rod"] = true, ["minecraft:lava_bucket"] = true}
  22.  
  23. local empty_bucket = { ["minecraft:bucket"] = true, ["minecraft:lava_bucket"] = true}
  24.  
  25.  
  26.  
  27. local function getCoal(stack_info)
  28.   if computer.energy() <=200 then
  29. robot.select(5) ; robot.drop() ; robot.select(16) ; robot.drop()
  30. robot.select(14) ; robot.place() ; robot.select(15)
  31.    if stack_info == nil then
  32.     return false
  33.   end
  34.   for index, known_fuel_name in ipairs(Coal_names) do
  35.     if stack_info.name == known_fuel_name then
  36.       return true
  37.     end
  38.   end
  39.   return false
  40. end
  41.  
  42. for slot=1,27 do
  43.  local stack_info = inventory.getStackInSlot(side, slot)
  44.  if fuel_names[stack_info.name] then
  45.     print(stack_info.name, "found in slot", slot)
  46.     inventory.suckFromSlot(sides.front, slot)
  47.     break
  48.   end
  49. end
  50. robot.select(16) ; inventory.dropIntoSlot(side, 1) ; robot.select(5) ; robot.swing() ; robot.transferTo(14)
  51. end
  52.  
  53. getCoal(stack_info)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement