Bonkie

Quarry turtle Item Flow

May 18th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.14 KB | None | 0 0
  1. function sleepAdv(time)
  2.   matched=false
  3.   while time>0 do
  4.     if ((time-60)>45) then
  5.       sl = 60
  6.       matched=true
  7.     elseif ((time-45)>29 and matched==false) then
  8.       sl = 45
  9.       matched=true
  10.     elseif ((time-30)>14 and matched==false) then
  11.       sl = 30
  12.       matched=true
  13.     elseif ((time-15)>9 and matched==false) then
  14.       sl = 15
  15.       matched=true
  16.     elseif ((time-10)>4 and matched==false) then
  17.       sl = 10
  18.       matched=true
  19.     elseif ((time-5)>1 and matched==false) then
  20.       sl = 5
  21.       matched=true
  22.     else
  23.       sl = 1
  24.     end
  25.     print("Sleeping: ".. time)
  26.     time = time-sl
  27.     sleep(sl)
  28.     matched=false
  29.   end
  30. end
  31.  
  32. function itemFlowCheck()
  33.   sleepfor = 1
  34.   wait = true
  35.   tellertrue = 0
  36.   while wait==true do
  37.     check = redstone.getInput("back")
  38.     if (check==false) then
  39.       print("Sleeping for next check")
  40.       sleepAdv(sleepfor)
  41.       tellertrue=0
  42.       if (sleepfor<60) then
  43.         sleepfor = sleepfor+1
  44.       end
  45.     elseif (check==true) then
  46.       print("Inventory Empty.")
  47.       print("Number of empty checks to go: ".. 15-tellertrue)
  48.       print("Sleeping before check if inventory is still empty.")
  49.       tellertrue = tellertrue+1
  50.       sleepfor = 1
  51.       sleep(2)
  52.     end
  53.  
  54.     if (tellertrue>15) then
  55.       wait=false
  56.     else
  57.       wait=true
  58.     end
  59.   end
  60. end
  61.  
  62. wr = peripheral.wrap("right")
  63. freqAchter = 213
  64. freqQuarry = 206
  65.  
  66.  
  67. itemFlowCheck()
  68.  
  69. print("Retrieving Quarry")
  70. wr.setFreq(freqQuarry)
  71. wr.set(false)
  72.  
  73. while true do
  74.   print("Waiting for run Command")
  75.   if (os.pullEvent("redstone")) then
  76.     if(redstone.getInput("left")) then
  77.       print("Moving Frame")
  78.       wr.setFreq(freqAchter)
  79.       for i=1,9 do
  80.         wr.set(true)
  81.         sleepAdv(1)
  82.         wr.set(false)
  83.         sleepAdv(1)
  84.       end
  85.  
  86.       print("Place Quarry")
  87.       wr.setFreq(freqQuarry)
  88.       wr.set(true)
  89.  
  90.       print("Sleeping for 3 minutes for the quarry to start gathering resources")
  91.       sleepAdv(300)
  92.       print("Starting flow check")
  93.       itemFlowCheck()
  94.  
  95.       print("Retrieving Quarry")
  96.       wr.setFreq(freqQuarry)
  97.       wr.set(false)
  98.     end
  99.   end
  100. end
Advertisement
Add Comment
Please, Sign In to add comment