Advertisement
Greyman27

collect_lumber.lua

Nov 22nd, 2024 (edited)
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.23 KB | None | 0 0
  1. --collect items from chop_modded.lua
  2.  
  3. os.loadAPI("grey_api/move.lua")
  4. os.loadAPI("grey_api/util.lua")
  5.  
  6. local collect_location = {0,-6,0,0}
  7. local log_location = {0,0,0,0}
  8. local log = "minecraft:oak_log"
  9. local misc_location = {0,1,0,0}
  10. local fuel_location = {0,2,0,0}
  11. local fuel = "minecraft:coal"
  12. local fuels = {fuel, "minecraft:stick", log}
  13. local fuel_locations = {{0,2,0,0},
  14.                         {0,0,0,0}}
  15. local sapling_location = {0,3,0,0}
  16. local sapling = "minecraft:oak_sapling"
  17. local seconds_to_wait = 60*20
  18. local wait_first = false
  19. local offset_time = 60*2
  20. local min_fuel_level = 100
  21.  
  22. function refuel()
  23.     print("refueling")
  24.     while turtle.getFuelLevel() <= min_fuel_level and util.fuel(1,fuels) do end
  25.     if turtle.getFuelLevel()<=0 then
  26.         print("out of fuel")
  27.     elseif turtle.getFuelLevel()<=min_fuel_level then
  28.         print("low on fuel")
  29.     end
  30. end
  31.  
  32. function collect()
  33.     print("collecting")
  34.     move.goto(collect_location[1],collect_location[2],collect_location[3],collect_location[4])
  35.     while turtle.suckDown() and not util.is_full() do end
  36. end
  37.  
  38. function deposit_logs()
  39.     print("depositing logs")
  40.     local i = 1
  41.     for i=1,16 do
  42.         if turtle.getItemCount(i)>0 and turtle.getItemDetail(i)["name"]==log then
  43.             move.goto(log_location[1],log_location[2],log_location[3],log_location[4])
  44.             turtle.select(i)
  45.             turtle.drop()
  46.         end
  47.     end
  48. end
  49.  
  50. function deposit_fuel()
  51.     print("depositing fuel")
  52.     local i = 1
  53.     for i=1,16 do
  54.         if turtle.getItemCount(i)>0 and turtle.getItemDetail(i)["name"]==fuel then
  55.             move.goto(fuel_location[1],fuel_location[2],fuel_location[3],fuel_location[4])
  56.             turtle.select(i)
  57.             turtle.drop()
  58.         end
  59.     end
  60. end
  61.  
  62. function deposit_saplings()
  63.     print("depositing saplings")
  64.     local i = 1
  65.     for i=1,16 do
  66.         if turtle.getItemCount(i)>0 and turtle.getItemDetail(i)["name"]==sapling then
  67.             move.goto(sapling_location[1],sapling_location[2],sapling_location[3],sapling_location[4])
  68.             turtle.select(i)
  69.             turtle.drop()
  70.         end
  71.     end
  72. end
  73.  
  74. function deposit_misc()
  75.     print("depositing misc")
  76.     local i = 1
  77.     for i=1,16 do
  78.         if turtle.getItemCount(i)>0 then
  79.             move.goto(misc_location[1],misc_location[2],misc_location[3],misc_location[4])
  80.             turtle.select(i)
  81.             turtle.drop()
  82.         end
  83.     end
  84. end
  85.  
  86. function pick_up_fuel()
  87.     print("picking up fuel")
  88.     local fuel_max = 64
  89.     local fuel_needed = fuel_max
  90.     i = 1
  91.     while fuel_needed > 0 and i <= #fuel_locations do
  92.         move.goto(fuel_locations[i][1],fuel_locations[i][2],fuel_locations[i][3],fuel_locations[i][4])
  93.         turtle.suck(fuel_needed)
  94.         fuel_needed = fuel_max - util.count_all_items()
  95.        
  96.         i = i+1
  97.     end
  98.     if fuel_needed > 0 then
  99.         print("Couldn't find max fuel stores")
  100.     end
  101. end
  102.  
  103. if wait_first then util.wait(seconds_to_wait) end
  104. util.wait(offset_time)
  105. while true do
  106.     refuel()
  107.     collect()
  108.     refuel()
  109.     deposit_logs()
  110.     deposit_fuel()
  111.     deposit_saplings()
  112.     deposit_misc()
  113.    
  114.     pick_up_fuel()
  115.    
  116.     --wait for next harvest
  117.     move.goto(0,0,0,0)
  118.     util.wait(seconds_to_wait)
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement