View difference between Paste ID: gXky9GMy and 57mpd8BE
SHOW: | | - or go back to the newest paste.
1
remoteID = 13
2
--the ID of the remote computer
3
4
rednet.open("right")
5
 
6
while true do
7
 
8
  sendID, msg, prot = rednet.receive()
9
10
  function digBlock()
11
    while turtle.detect() do
12
      turtle.dig()
13
    end
14
  end
15
 
16
  function move(direction)
17
    if direction == "up" then
18
   
19
      while turtle.up() == false do
20
        turtle.digUp()
21
        turtle.attackUp()
22
      end
23
     
24
    elseif direction == "down" then
25
   
26
      while turtle.down() == false do
27
        turtle.digDown()
28
        turtle.attackDown()
29
      end
30
     
31
    elseif direction == "forward" then
32
   
33
      while turtle.forward() == false do
34
        turtle.dig()
35
        turtle.attack()
36
      end
37
    end
38
  end
39
40
  function itemDump()
41
    for slot=1,16 do
42
      if turtle.getItemCount(slot) > 0 then
43
        turtle.select(slot)
44
        turtle.drop()
45
      end
46
    end
47
  end
48
   
49
  if msg[1] == "cube" then
50
   
51
    rednet.send(remoteID, "ill mine out a " .. msg[2] .. " x " .. msg[3] .. " x " .. msg[4] .. " cuboid")
52
    frontBlocks = msg[2]
53
    rightBlocks = msg[3]
54
    upBlocks = msg[4]
55
   
56
    turtle.dig()
57
    move("forward")
58
     
59
    function line()
60
      for i=1,frontBlocks -1 do
61
        turtle.dig()
62
        move("forward")
63
      end
64
    end
65
     
66
    function panel()
67
      line()
68
      for i=1,upBlocks -1 do
69
        turtle.digUp()
70
        move("up")
71
        turtle.turnRight()
72
        turtle.turnRight()
73
        line()
74
      end
75
    end
76
     
77
    function turn()
78
      digBlock()
79
      turtle.select(1)
80
      turtle.place()
81
      itemDump()
82
      turtle.select(1)
83
      turtle.dig()
84
      move("forward")
85
      turtle.turnLeft()
86
    end
87
     
88
    function cuboid()
89
      panel()
90
      m = 0
91
      for i=1,rightBlocks -1 do
92
        m = m + 1
93
        if m == 1 and upBlocks%2 == 1 then
94
          m = 0
95
          turtle.turnRight()
96
          turtle.turnRight()
97
          for i=1,frontBlocks - 1 do
98
            move("forward")
99
          end
100
          for i=1,upBlocks - 1 do
101
            move("down")
102
          end
103
          turtle.turnLeft()
104
          turn()
105
          panel()
106
        elseif math.fmod(upBlocks,2) ~= 1 then
107
          turtle.turnLeft()
108
         
109
          for i=1,upBlocks - 1 do
110
            move("down")
111
          end
112
         
113
          turn()
114
          panel()
115
         
116
        end
117
      end
118
    end
119
     
120
    cuboid()
121
    if math.fmod(upBlocks,2) ~= 1 then
122
      turtle.turnRight()
123
      for i=1,upBlocks - 1 do
124
        move("down")
125
      end
126
     
127
      for i=1,rightBlocks - 1 do
128
        move("forward")
129
      end
130
    else
131
      turtle.turnRight()
132
      turtle.turnRight()
133
     
134
      for i=1,frontBlocks - 1 do
135
        move("forward")
136
      end
137
     
138
      turtle.turnRight()
139
     
140
      for i=1,upBlocks - 1 do
141
        move("down")
142
      end
143
     
144
      for i=1,rightBlocks - 1 do
145
        move("forward")
146
      end
147
    end
148
     
149
    turtle.turnLeft()
150
    turtle.dig()
151
    turtle.select(1)
152
    turtle.place()
153
    itemDump()
154
    turtle.select(1)
155
    turtle.dig()
156
   
157
   
158
  elseif msg[1] == "tree" then
159
    rednet.send(remoteID, "i'll cut down this tree")
160
    move("forward")
161
   
162
    moved = 0
163
   
164
    while turtle.digUp() == true do
165
      move("up")
166
      moved = moved + 1
167
    end
168
   
169
    while moved > 0 do
170
      move("down")
171
      moved = moved - 1
172
    end
173
   
174
  elseif msg[1] == "move" then
175
    rednet.send(remoteID, "i'll move " .. msg[2] .. " " .. msg[3] .. " blocks")
176
    moveBlocks = tonumber(msg[3])
177
    moveTo = msg[2]
178
   
179
    if moveTo == "right" then
180
      turtle.turnRight()
181
      moveTo = "forward"
182
     
183
    elseif moveTo == "left" then
184
      turtle.turnLeft()
185
      moveTo = "forward"
186
     
187
    elseif moveTo == "back" then
188
      for i=1,2 do
189
        turtle.turnRight()
190
      end
191
      moveTo = "forward"
192
         
193
    end
194
   
195
    while moveBlocks > 0 do
196
      if moveTo == "up" then
197
        move("up")
198
     
199
      elseif moveTo == "down" then
200
        move("down")
201
       
202
      elseif moveTo == "forward" then
203
        move("forward")
204
     
205
      end
206
      moveBlocks = moveBlocks - 1
207
    end
208
  elseif msg[1] == "dumpItems" then
209
    rednet.send(remoteID, "dumping items into enderchest...")
210
   
211
       
212
    digBlock()
213
    turtle.select(1)
214
    turtle.place()
215
    itemDump() 
216
    turtle.select(1)
217
    turtle.dig()
218
  else
219
  rednet.send(remoteID, "unknown program type help for options")
220
 
221
  end
222
end