Advertisement
feline-dis

Untitled

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