Advertisement
feline-dis

Untitled

Dec 22nd, 2020 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. local slotCount = 16
  2. local width = 10
  3. local length = 10
  4. local height = 3
  5.  
  6. local trash = {
  7. "minecraft:cobblestone", "minecraft:dirt", "minecraft:andesite",
  8. "minecraft:diorite", "minecraft:clay", "minecraft:sand",
  9. "minecraft:sandstone", "minecraft:limestone"
  10. }
  11.  
  12. function purgeTrash()
  13. for slot = 1, slotCount, 1 do
  14. local item = turtle.getItemDetail(slot)
  15.  
  16. if (item ~= nil) then
  17. for key, value in pairs(trash) do
  18. if (value == item.name) then end
  19. end
  20. end
  21.  
  22. end
  23. end
  24.  
  25. function forEach(table, func)
  26. for k, v in pairs(table) do func(v) end
  27. return true
  28. end
  29.  
  30. function checkFuel()
  31. print('Checkng fuel...')
  32. if (turtle.getFuelLevel() < 20000) then
  33. for slot = 1, slotCount, 1 do
  34. local item = turtle.getItemDetail(slot)
  35. if (item ~= nil) then
  36. if (item.name == "minecraft:coal") then
  37. print('Attemping to refuel...')
  38.  
  39. turtle.select(slot)
  40.  
  41. local result = turtle.refuel()
  42.  
  43. print('Turtle refueled...')
  44.  
  45. return true
  46. end
  47. end
  48. end
  49. print('Did not find coal in inventory.. powering down D:')
  50. return false
  51. end
  52. end
  53.  
  54. function main()
  55. local active = true
  56. while active do
  57. for level = 1, height, 1 do
  58. for row = 1, width, 1 do
  59. for col = 1, length, 1 do
  60. if (checkFuel() == false) then active = false end
  61. end
  62. purgeTrash()
  63. end
  64. if (level == height and col == length) then
  65. active = false
  66. end
  67. end
  68. end
  69.  
  70. end
  71.  
  72. main()
  73.  
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement