View difference between Paste ID: J4bcwtGy and 32FH1p2J
SHOW: | | - or go back to the newest paste.
1
--[[
2
Auflistung Materialien:
3
01 Fußboden innen:   40
4
02 Fußboden Veranda:  6
5-
03 Treppen Veranda:   9
5+
03 Halfsteps:        44
6
04 Sockel:           26
7
05 Wände Typ 1:      63
8
06 Wände Typ 2:      46
9
07 Fenster:          15
10
08 Türen:             1
11
09 Trittplatte:       1
12
10 Craftingtable:     1
13
11 Truhen:            2
14-
12 Fackeln:           4
14+
12 Fackeln:           9
15-
13 Öfen:              5
15+
13 Öfen:              4
16
14 Dach:             64
17
15 Dach:             48
18
16 Giebel:           10
19
20
http://pastebin.com/J4bcwtGy
21
22
23
24
        Minecraft Turtle: Simple House
25
        2013-12-13 (c) psychedelixx / thebiglebowski33
26
 
27
        Builds a simple house
28
 
29
        Usage:
30
        - use turtle and type "label set <name>"
31
          (to give your turtle an unique name so it remembers its programs)
32
        - type "pastebin get J4bcwtGy house"
33
--]]
34
 
35
--[[ --- Konstanten --- ]]--
36
dirCounter = 1
37
 
38
countList={}
39
keyFloorIn    = "1"
40
keyFloorOut   = "2"
41-
keyStairsOut  = "3"
41+
halfSteps     = "3"
42
keySocket     = "4"
43
keyWalls1     = "5"
44
keyWalls2     = "6"
45
keyWindows    = "7"
46
keyDoors      = "8"
47
keyPressPlate = "9"
48
keyCraftTable = "10"
49
keyChests     = "11"
50
keyTorches    = "12"
51
keyFurnaces   = "13"
52
keyRoof1      = "14"
53
keyRoof2      = "15"
54
keyGable      = "16"
55
 
56
countList[keyFloorIn]    = 40
57
countList[keyFloorOut]   = 6
58-
countList[keyStairsOut]  = 9
58+
countList[halfSteps]     = 44
59
countList[keySocket]     = 26
60
countList[keyWalls1]     = 63
61
countList[keyWalls2]     = 46
62
countList[keyWindows]    = 15
63
countList[keyDoors]      = 1
64
countList[keyPressPlate] = 1
65
countList[keyCraftTable] = 1
66
countList[keyChests]     = 2
67-
countList[keyTorches]    = 4
67+
countList[keyTorches]    = 9
68-
countList[keyFurnaces]   = 5
68+
countList[keyFurnaces]   = 4
69
countList[keyRoof1]      = 64
70
countList[keyRoof2]      = 48
71
countList[keyGable]      = 10
72
 
73
--[[
74
for key, value in pairs(countList) do
75
    print (key, " = " , value)
76
end
77
]]--
78
 
79
--[[ --- Parameter ---- ]]--
80
local args = { ... }
81
if #args < 1 then
82
        print("")
83
end
84
--[[arg1 = tonumber(args[1])]]--
85
 
86
--[[ --- Item Check --- ]]--
87
function enoughResources()
88
    for key, value in pairs(countList) do
89
        if turtle.getItemCount(tonumber(key)) < value then
90
            return false
91
        end
92
    end
93
    return true
94
end  
95
96
function calcFuel(blueprint)
97
    return #blueprint*#blueprint[1]*#blueprint[1][1]
98
end
99
 
100
function turn()
101
    if dirCounter%2 == 1 then
102
        t.right()
103
        t.forward()
104
        t.right()
105
    else
106
        t.left()
107
        t.forward()
108
        t.left()
109
    end
110
 
111
    dirCounter = dirCounter + 1
112
end
113
 
114
function buildHouse(blueprint)
115
   
116
    t.up()
117
118
    yMax = #blueprint
119
    y = 1
120
121
    while y <= #blueprint do
122
        zMax = #blueprint[y]
123
        z = 1
124
    
125
        while z <= zMax do
126
            xMax = #blueprint[y][z]
127
            
128
            if dirCounter%2 == 1 then 
129
                x = 1
130
            else 
131
                x = xMax
132
            end
133
    
134
            while (x <= xMax and dirCounter%2 == 1) 
135
               or (x >= 1 and dirCounter%2 == 0) do
136
                slot = blueprint[y][z][x]
137
                
138
                print("x: ", x, "/", xMax, " - ", 
139
                      "z: ", z, "/", zMax, " - ", 
140
                      "y: ", y, "/", yMax, " - ", 
141
                      "slot: ", slot)
142
                      
143
                if slot > 0 then
144
                    
145
                    if turtle.getItemCount(slot) == 0 and
146
                       slot == 14 then
147
                        slot = 15
148
                    end
149
		    if slot == 13 then
150
			t.left()
151
		    end
152
153
                    t.placeDown(slot)
154
155
		    if slot == 13 then
156
			t.right()
157
		    end
158
                end
159
                if (x < xMax and dirCounter%2 == 1) 
160
                 or(x > 1 and dirCounter%2 == 0) then
161
                    t.forward()
162
                end
163
                
164
                if dirCounter%2 == 1 then
165
                    x = x+1
166
                else
167
                    x = x-1
168
                end
169
            end
170
            
171
            if z < zMax then
172
                turn()
173
            end
174
            z = z+1
175
        end
176
177
        if y < yMax then
178
            driveToStartPos(blueprint, y)
179
        else
180
            t.forward()
181
            for y = 1, yMax, 1 do
182
                t.down()
183
            end
184
            print("Finished!")
185
            print("All your base are belong to us")  
186
        end
187
        y = y+1
188
    end
189
end
190
191
--[[ Funktion Rückfahrt: ]]--
192
function driveToStartPos(array, y)     
193
    print("Driving to start position")  
194
    if dirCounter%2 == 0 then 
195
        t.right()
196
    else
197
        t.right()
198
        t.right()
199
        for x = 1, #array[y][#array[y]]-1, 1 do
200
            t.forward()
201
        end
202
        t.right()
203
    end
204
     
205
    for z = 1, #array[y]-1, 1 do
206
        t.forward()
207
    end
208
      
209
    t.right()
210
    t.up()
211
    dirCounter = 1
212
end
213
214
function start()
215
    if enoughResources() or 1 == 1 then
216
        print("forwards, to the moon, alice")
217
218
        t.forward(12)
219
        t.right()
220
        layer    = {}
221
--[[        
222
        layer[1] = {{1, 1, 1,1},
223
                    {1, 2, 2,1},
224
                    {1, 2, 2,1},
225
                    {1, 1, 1,1}}
226
        layer[2] = {{2, 2, 2, 2},
227
                    {2, 1, 1, 2},
228
                    {2, 1, 1, 2},
229
                    {2, 2, 2, 2}}
230
]]--                    
231
          
232
233
        layer[1] = {{ 0, 6, 4, 4, 4, 4, 4, 6, 0},
234
                    { 0, 4, 1, 1, 1, 1, 1, 4, 0},
235
                    { 0, 4, 1, 1, 1, 1, 1, 4, 0},
236
                    { 0, 4, 1, 1, 1, 1, 1, 4, 0},
237
                    { 0, 4, 1, 1, 1, 1, 1, 4, 0},
238
                    { 0, 4, 1, 1, 1, 1, 1, 4, 0},
239
                    { 0, 4, 1, 1, 1, 1, 1, 4, 0},
240
                    { 0, 4, 1, 1, 1, 1, 1, 4, 0},
241
                    { 0, 4, 1, 1, 1, 1, 1, 4, 0},
242
                    { 0, 6, 4, 2, 4, 4, 4, 6, 0},
243
                    { 0, 3, 2, 2, 2, 2, 2, 3, 0},
244-
                    { 0, 5, 0, 9,11,11,10, 5, 0},
244+
245
246
        layer[2] = {{ 0, 6, 5, 5, 5, 5, 5, 6, 0},
247
                    { 0, 5,13,13,13,13, 1, 5, 0},
248
                    { 0, 5, 0, 0, 0, 0, 1, 5, 0},
249
                    { 0, 5, 0, 0, 0, 0, 1, 5, 0},
250
                    { 0, 5, 0, 0, 0, 0, 0, 5, 0},
251
                    { 0, 5, 0, 0, 0, 0, 0, 5, 0},
252
                    { 0, 5, 0, 0, 0, 0, 0, 5, 0},
253
                    { 0, 5, 0, 0, 0, 0, 0, 5, 0},
254
                    { 0, 5, 0, 9, 0, 0,10, 5, 0},
255
                    { 0, 6, 5, 8, 5, 5, 5, 6, 0}}
256
257
        layer[3] = {{ 0, 6, 5, 7, 7, 7, 5, 6, 0},
258
                    { 0, 5, 0, 0, 0,12, 1, 5, 0},
259
                    { 0, 5,12, 0, 0, 0, 1, 5, 0},
260
                    { 0, 7, 0, 0, 0, 0, 0, 7, 0},
261
                    { 0, 7, 0, 0, 0, 0, 0, 7, 0},
262
                    { 0, 7, 0, 0, 0, 0, 0, 7, 0},
263
                    { 0, 7, 0, 0, 0, 0, 0, 7, 0},
264
                    { 0, 5, 0, 0, 0, 0,12, 5, 0},
265
                    { 0, 5,12, 0, 0, 0, 0, 5, 0},
266
                    { 0, 6, 5, 0, 7, 7, 5, 6, 0},
267
                    { 0, 0,12, 0, 0, 0, 0, 0, 0}}
268
269
        layer[4] = {{ 0, 6, 5, 5, 5, 5, 5, 6, 0},
270
                    { 0, 5, 3, 3, 3, 3, 1, 5, 0},
271-
                    {14, 0, 0, 0, 0, 0, 0, 0,14},
271+
272-
                    {14, 0, 0, 0, 0, 0, 0, 0,14},
272+
273-
                    {14, 0, 0, 0, 0, 0, 0, 0,14},
273+
274-
                    {14, 0, 0, 0, 0, 0, 0, 0,14},
274+
275-
                    {14, 0, 0, 0, 0, 0, 0, 0,14},
275+
276-
                    {14, 0, 0, 0, 0, 0, 0, 0,14},
276+
277-
                    {14, 0, 0, 0, 0, 0, 0, 0,14},
277+
278-
                    {14, 0, 0, 0, 0, 0, 0, 0,14},
278+
279
280
        layer[5] = {{14, 6, 6, 6, 6, 6, 6, 6,14},
281-
        layer[6] = {{ 0,14, 6, 6, 6, 6, 6,14, 0},
281+
                    {14,14,11, 0, 0, 0, 0, 0,14},
282
                    {14,14,11, 0, 0, 0, 0, 0,14},
283
                    {14,14, 0, 0, 0, 0, 0, 0,14},
284
                    {14,14,11, 0, 0, 0, 0, 0,14},
285
                    {14,14,11, 0, 0, 0, 0, 0,14},
286
                    {14,14, 0, 0, 0, 0, 0, 0,14},
287
                    {14,14,11, 0, 0, 0, 0, 0,14},
288
                    {14,14,11, 0, 0, 0, 0, 0,14},
289
                    {14, 6, 6, 6, 6, 6, 6, 6,14}}
290-
                    { 0,14, 6, 6, 6, 6, 6,14, 0}}
290+
291
        layer[6] = {{ 0,14, 6, 6, 7, 6, 6,14, 0},
292-
        layer[7] = {{ 0, 0,14, 6, 7, 6,14, 0, 0},
292+
293
                    { 0,14, 0, 0, 0, 0, 0,14, 0},
294
                    { 0,14, 0, 0, 0, 0, 0,14, 0},
295
                    { 0,14, 0, 0, 0, 0, 0,14, 0},
296
                    { 0,14, 0, 0, 0, 0, 0,14, 0},
297
                    { 0,14, 0, 0, 0, 0, 0,14, 0},
298
                    { 0,14, 0, 0, 0, 0, 0,14, 0},
299
                    { 0,14, 0, 0, 0, 0, 0,14, 0},
300
                    { 0,14, 6, 6, 7, 6, 6,14, 0}}
301-
                    { 0, 0,14, 6, 7, 6,14, 0, 0}}
301+
302
        layer[7] = {{ 0, 0,14, 6, 6, 6,14, 0, 0},
303
                    { 0, 0,14, 0, 0, 0,14, 0, 0},
304
                    { 0, 0,14,12, 0, 0,14, 0, 0},
305
                    { 0, 0,14, 0, 0,12,14, 0, 0},
306
                    { 0, 0,14, 0, 0, 0,14, 0, 0},
307
                    { 0, 0,14, 0, 0, 0,14, 0, 0},
308
                    { 0, 0,14,12, 0, 0,14, 0, 0},
309
                    { 0, 0,14, 0, 0,12,14, 0, 0},
310
                    { 0, 0,14, 0, 0, 0,14, 0, 0},
311
                    { 0, 0,14, 6, 6, 6,14, 0, 0}}
312
313
        layer[8] = {{ 0, 0, 0,14, 6,14, 0, 0, 0},
314
                    { 0, 0, 0,14, 0,14, 0, 0, 0},
315
                    { 0, 0, 0,14, 0,14, 0, 0, 0},
316
                    { 0, 0, 0,14, 0,14, 0, 0, 0},
317
                    { 0, 0, 0,14, 0,14, 0, 0, 0},
318
                    { 0, 0, 0,14, 0,14, 0, 0, 0},
319
                    { 0, 0, 0,14, 0,14, 0, 0, 0},
320
                    { 0, 0, 0,14, 0,14, 0, 0, 0},
321
                    { 0, 0, 0,14, 0,14, 0, 0, 0},
322
                    { 0, 0, 0,14, 6,14, 0, 0, 0}}
323
324
        layer[9] = {{ 0, 0, 0, 0,16, 0, 0, 0, 0},
325
                    { 0, 0, 0, 0,16, 0, 0, 0, 0},
326
                    { 0, 0, 0, 0,16, 0, 0, 0, 0},
327
                    { 0, 0, 0, 0,16, 0, 0, 0, 0},
328
                    { 0, 0, 0, 0,16, 0, 0, 0, 0},
329
                    { 0, 0, 0, 0,16, 0, 0, 0, 0},
330
                    { 0, 0, 0, 0,16, 0, 0, 0, 0},
331
                    { 0, 0, 0, 0,16, 0, 0, 0, 0},
332
                    { 0, 0, 0, 0,16, 0, 0, 0, 0},
333
                    { 0, 0, 0, 0,16, 0, 0, 0, 0}}
334
                    
335
        if turtle.getFuelLevel() < calcFuel(layer) then
336
            print("Amount of missing fuel: ", calcFuel(layer)-turtle.getFuelLevel())
337
            print("Missing fuel in coal: ", calcFuel(layer)-turtle.getFuelLevel()/80+1)
338
            print("Fill fuel in slot 1, type 'refuel <amount>' and try again")
339
            error()
340
        end
341
        
342
        buildHouse(layer)
343
    else
344
        print("Not enough Resources")
345
    end
346
end
347
348
349
print("======== 2013 (c) psy & lebo ==========")
350
print("======== Simple House Builder =========")
351
352
start()