View difference between Paste ID: K0vxFcyJ and ERpDc9Gk
SHOW: | | - or go back to the newest paste.
1
local out = false
2
wd = false
3
sd = false
4
5
function dump()
6
 turtle.back()
7
 turtle.turnLeft()
8
 turtle.turnLeft()
9
 turtle.select(3)
10
 turtle.drop()
11
 turtle.select(4)
12
 turtle.drop()
13
 turtle.turnLeft()
14
 turtle.turnLeft()
15
 turtle.forward()
16
end
17
18
function forward()
19
 while not turtle.forward() do
20
   turtle.attack()
21
 end
22
end
23
24
function checkInv()
25
 if turtle.getItemCount(1) <= 7 then
26
   out = true
27
 else
28
   out = false
29
 end
30
 if turtle.getItemCount(2) <= 7 then
31
   out = true
32
 else
33
   out = false
34
 end
35
end
36
37
function wood()
38
  turtle.select(4)
39
  turtle.digDown()
40
 if turtle.getItemCount(2) == 0 then
41
  if turtle.getItemCount(1) == 0 then
42
    wd = false
43
  else
44
    turtle.select(1)
45
    turtle.placeDown()
46
  end
47
 else
48
   turtle.select(2)
49
   turtle.placeDown()
50
   wd = true
51
 end
52
end
53
54
function stone()
55
  turtle.select(3)
56
  turtle.digDown()
57
 if turtle.getItemCount(1) == 0 then
58
  if turtle.getItemCount(2) == 0 then
59
    sd = false
60
  else
61
    turtle.select(2)
62
    turtle.placeDown()
63
  end
64
 else
65
   turtle.select(1)
66
   turtle.placeDown()
67
   sd = true
68
 end
69
end
70
71
function refuel()
72
  checkInv()
73
 if out == true then
74
   turtle.back()
75
   turtle.select(1)
76
   local xa = 64 - turtle.getItemCount(1)
77
   local xb = 64 - turtle.getItemCount(2)
78
   turtle.suckDown(xa)
79
   turtle.suckUp(xb)
80
   turtle.forward()
81
   out = false
82
 end
83
  checkInv()
84
end
85
86
function replace()
87
  success, t = turtle.inspectDown()
88
 if t.name == "Botania:livingwood" then
89
   wood()
90
 elseif t.name == "Botania:livingrock" then
91
   stone()
92
 end
93
end
94
95
function supply()
96
  term.setCursorPos(1,9)
97
 if wd == true and sd == true then
98
   print("Turtle is out of wood and  stone")
99
 elseif wd == true then
100
   print("turtle is out of wood")
101
 elseif wd == true then
102
   print("turtle is out of stone")
103
 end
104
end
105
106
while true do
107
  fl = turtle.getFuelLevel()
108
  success, t = turtle.inspectDown()
109
 if t.name == "Botania:livingwood" or t.name == "Botania:livingrock" then
110
   term.clear()
111
   term.setCursorPos(10,6)
112
   print("STATUS: WORKING")
113
   term.setCursorPos(12,7)
114
   print("FUEL: "..fl)
115
   supply()
116
   refuel()
117
   replace()
118
  for i=1,5 do
119
    forward()
120
    replace()
121
  end
122
   turtle.turnLeft()
123
   forward()
124
   turtle.turnLeft()
125
   replace()
126
   forward()
127
   forward()
128
   replace()
129
   forward()
130
   replace()
131
   forward()
132
   forward()
133
   replace()
134
   turtle.turnRight()
135
   forward()
136
   turtle.turnRight()
137
   replace()
138
  for i = 1,5 do
139
    forward()
140
    replace()
141
  end
142
  for i=1,5 do
143
    turtle.back()
144
  end
145
   turtle.turnRight()
146
   turtle.forward()
147
   turtle.forward()
148
   turtle.turnLeft()
149
   dump()
150
 else 
151
   term.clear()
152
   term.setCursorPos(10,6)
153
   print("STATUS: Waiting")
154
   term.setCursorPos(12,7)
155
   print("FUEL: "..fl)
156
   supply()
157
   sleep(10)
158
 end
159
end