-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzfarm
executable file
·137 lines (118 loc) · 2.12 KB
/
zfarm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
-- Zombie pigman farm using portals
local portalCount = 3
local length = 1 + 3*portalCount
local turnDir = "left"
local currentSlot
local placeFunctions = {}
placeFunctions["down"] = turtle.placeDown
placeFunctions["up"] = turtle.placeUp
placeFunctions[""] = turtle.place
function forward(count)
if count == nil then
count = 1
end
for i = 1,count do
turtle.forward()
end
end
function back(count)
if count == nil then
count = 1
end
for i = 1,count do
turtle.back()
end
end
function changeTurnDir()
if turnDir == "left" then
turnDir = "right"
elseif turnDir == "right" then
turnDir = "left"
else
print("Unknown turn dir")
exit(1)
end
end
function autoTurn()
if turnDir == "left" then
turtle.turnLeft()
elseif turnDir == "right" then
turtle.turnRight()
else
print("Unknown turn dir")
exit(1)
end
end
function place(dir)
if turtle.getItemCount(currentSlot) == 0 then
if currentSlot < 8 then
selectSlot(currentSlot+1)
else
print("out of items")
exit(1)
end
end
if dir == nil then dir = "" end
return placeFunctions[dir]()
end
function selectSlot(num)
turtle.select(num)
currentSlot=num
end
function buildRows()
for i = 1,portalCount+1 do
for step = 1,length do
place("down")
if step < length then
forward()
end
end
if i < portalCount+1 then
autoTurn()
forward(3)
autoTurn()
changeTurnDir()
end
end
end
function buildColumns(move)
for i = 1,portalCount+1 do
for step = 1,portalCount+1 do
place("down")
place("up")
if step == portalCount+1 then
autoTurn()
end
move()
place()
if step < portalCount+1 then
move(2)
end
end
if i < portalCount+1 then
move(2)
autoTurn()
changeTurnDir()
end
end
end
function build()
buildRows()
changeTurnDir()
autoTurn()
buildRows()
turtle.up()
autoTurn()
changeTurnDir()
buildColumns(back)
turtle.up()
turtle.up()
turtle.up()
forward()
turnDir="left"
buildRows()
changeTurnDir()
autoTurn()
buildRows()
end
selectSlot(1)