Advertisement
feline-dis

Untitled

Dec 22nd, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 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. print('fuel level sub-optimal')
  34. for slot = 1, slotCount, 1 do
  35. local item = turtle.getItemDetail(slot)
  36. if (item ~= nil) then
  37. if (item.name == "minecraft:coal") then
  38. print('Attemping to refuel...')
  39.  
  40. turtle.select(slot)
  41.  
  42. local result = turtle.refuel()
  43.  
  44. print('Turtle refueled...')
  45.  
  46. return true
  47. end
  48. end
  49. end
  50. print('Did not find coal in inventory.. powering down D:')
  51. return false
  52. end
  53. end
  54.  
  55. function main()
  56. local active = true
  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 active = false end
  65. end
  66. end
  67.  
  68. main()
  69.  
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement