SHOW:
|
|
- or go back to the newest paste.
1 | --Variables -- | |
2 | mouseWidth = 0 | |
3 | mouseHeight = 0 | |
4 | ||
5 | currentMob = "None" | |
6 | currentFarmStatus = "Off " | |
7 | currentSpawnerStatus = "Off " | |
8 | ||
9 | --Set turtle connection -- | |
10 | rednet.open("bottom") | |
11 | Turtle = 17 | |
12 | ||
13 | ||
14 | --Set monitor properties | |
15 | monitor = peripheral.wrap("left") | |
16 | monitor.clear() | |
17 | ||
18 | monitor.setCursorPos(1,1) | |
19 | ||
20 | w,h=monitor.getSize() | |
21 | ||
22 | --Write spawner status data -- | |
23 | monitor.setBackgroundColor((colors.blue)) | |
24 | monitor.setCursorPos(2,2) | |
25 | monitor.write("Farm control ") | |
26 | ||
27 | monitor.setBackgroundColor((colors.blue)) | |
28 | monitor.setCursorPos(2,4) | |
29 | monitor.write("Status ") | |
30 | ||
31 | --Write farm status data -- | |
32 | monitor.setBackgroundColor((colors.blue)) | |
33 | monitor.setCursorPos(20,2) | |
34 | monitor.write("Spawner control ") | |
35 | ||
36 | monitor.setBackgroundColor((colors.blue)) | |
37 | monitor.setCursorPos(20,4) | |
38 | monitor.write("Status ") | |
39 | ||
40 | function setCurrentFarmStatusData() | |
41 | if currentFarmStatus == "On " then | |
42 | monitor.setBackgroundColor((colors.green)) | |
43 | elseif currentFarmStatus == "Off " then | |
44 | monitor.setBackgroundColor((colors.red)) | |
45 | end | |
46 | monitor.setCursorPos(10,4) | |
47 | monitor.write(currentFarmStatus) | |
48 | end | |
49 | ||
50 | function setCurrentSpawnerStatusData() | |
51 | if currentSpawnerStatus == "On " then | |
52 | monitor.setBackgroundColor((colors.green)) | |
53 | elseif currentSpawnerStatus == "Off " then | |
54 | monitor.setBackgroundColor((colors.red)) | |
55 | end | |
56 | monitor.setCursorPos(28,4) | |
57 | monitor.write(currentSpawnerStatus) | |
58 | end | |
59 | ||
60 | function setCurrentMobData() | |
61 | --Write first list of mobs | |
62 | monitor.setBackgroundColor((colors.red)) | |
63 | ||
64 | if currentMob == "Enderman" then | |
65 | monitor.setBackgroundColor((colors.green)) | |
66 | end | |
67 | monitor.setCursorPos(2,6) | |
68 | monitor.write(" Enderman ") | |
69 | monitor.setBackgroundColor((colors.red)) | |
70 | ||
71 | if currentMob == "Skeleton" then | |
72 | monitor.setBackgroundColor((colors.green)) | |
73 | end | |
74 | monitor.setCursorPos(2,8) | |
75 | monitor.write(" Skeleton ") | |
76 | monitor.setBackgroundColor((colors.red)) | |
77 | ||
78 | if currentMob == "Blaze" then | |
79 | monitor.setBackgroundColor((colors.green)) | |
80 | end | |
81 | monitor.setCursorPos(2,10) | |
82 | monitor.write(" Blaze ") | |
83 | monitor.setBackgroundColor((colors.red)) | |
84 | ||
85 | if currentMob == "Whisp" then | |
86 | monitor.setBackgroundColor((colors.green)) | |
87 | end | |
88 | monitor.setCursorPos(2,12) | |
89 | monitor.write(" Whisp ") | |
90 | monitor.setBackgroundColor((colors.red)) | |
91 | ||
92 | if currentMob == "Cow" then | |
93 | monitor.setBackgroundColor((colors.green)) | |
94 | end | |
95 | monitor.setCursorPos(2,14) | |
96 | monitor.write(" Cow ") | |
97 | monitor.setBackgroundColor((colors.red)) | |
98 | ||
99 | --Write second list of mobs | |
100 | if currentMob == "Ghast" then | |
101 | monitor.setBackgroundColor((colors.green)) | |
102 | end | |
103 | monitor.setCursorPos(16,6) | |
104 | monitor.write(" Ghast ") | |
105 | monitor.setBackgroundColor((colors.red)) | |
106 | ||
107 | if currentMob == "Chicken" then | |
108 | monitor.setBackgroundColor((colors.green)) | |
109 | end | |
110 | monitor.setCursorPos(16,8) | |
111 | monitor.write(" Chicken ") | |
112 | monitor.setBackgroundColor((colors.red)) | |
113 | ||
114 | monitor.setCursorPos(16,10) | |
115 | monitor.write(" None ") | |
116 | monitor.setBackgroundColor((colors.red)) | |
117 | ||
118 | monitor.setCursorPos(16,12) | |
119 | monitor.write(" None ") | |
120 | monitor.setBackgroundColor((colors.red)) | |
121 | ||
122 | if currentMob == "None" then | |
123 | monitor.setBackgroundColor((colors.green)) | |
124 | end | |
125 | monitor.setCursorPos(16,14) | |
126 | monitor.write(" None ") | |
127 | monitor.setBackgroundColor((colors.red)) | |
128 | end | |
129 | ||
130 | function changeFarmStatus() | |
131 | --Clicked Status -- | |
132 | if(currentFarmStatus == "On ") then | |
133 | currentFarmStatus = "Off " | |
134 | - | --Clicked Status -- |
134 | + | redstone.setOutput("right", true) |
135 | - | if(currentFarmStatus == "On ") then |
135 | + | elseif(currentFarmStatus == "Off ") then |
136 | - | currentFarmStatus = "Off " |
136 | + | currentFarmStatus = "On " |
137 | - | redstone.setOutput("right", true) |
137 | + | redstone.setOutput("right", false) |
138 | - | elseif(currentFarmStatus == "Off ") then |
138 | + | |
139 | - | currentFarmStatus = "On " |
139 | + | setCurrentFarmStatusData() |
140 | - | redstone.setOutput("right", false) |
140 | + | end |
141 | - | end |
141 | + | |
142 | - | setCurrentFarmStatusData() |
142 | + | function changeSpawnerStatus() |
143 | --Clicked Status -- | |
144 | if(currentSpawnerStatus == "On ") then | |
145 | currentSpawnerStatus = "Off " | |
146 | - | --Clicked Status -- |
146 | + | rednet.send(Turtle, "Off") |
147 | - | if(currentSpawnerStatus == "On ") then |
147 | + | elseif(currentSpawnerStatus == "Off ") then |
148 | - | currentSpawnerStatus = "Off " |
148 | + | currentSpawnerStatus = "On " |
149 | - | rednet.send(Turtle, "Off") |
149 | + | rednet.send(Turtle, "On") |
150 | - | elseif(currentSpawnerStatus == "Off ") then |
150 | + | |
151 | - | currentSpawnerStatus = "On " |
151 | + | setCurrentSpawnerStatusData() |
152 | - | rednet.send(Turtle, "On") |
152 | + | |
153 | - | end |
153 | + | |
154 | - | setCurrentSpawnerStatusData() |
154 | + | |
155 | function checkClickPosition() | |
156 | --Farm Status -- | |
157 | if(mouseWidth > 9 and mouseWidth < 14 and mouseHeight == 4) then | |
158 | changeFarmStatus() | |
159 | end | |
160 | --Spawner Status -- | |
161 | if(mouseWidth > 27 and mouseWidth < 32 and mouseHeight == 4) then | |
162 | changeSpawnerStatus() | |
163 | end | |
164 | -- 1st Row -- | |
165 | if(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 6) then | |
166 | --Clicked Enderman -- | |
167 | currentMob = "Enderman" | |
168 | setCurrentMobData() | |
169 | rednet.send(Turtle, 1) | |
170 | elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 6) then | |
171 | --Clicked Ghast-- | |
172 | currentMob = "Ghast" | |
173 | setCurrentMobData() | |
174 | rednet.send(Turtle, 6) | |
175 | -- 2nd Row -- | |
176 | elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 8) then | |
177 | --Clicked Skeleton -- | |
178 | currentMob = "Skeleton" | |
179 | setCurrentMobData() | |
180 | rednet.send(Turtle, 2) | |
181 | elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 8) then | |
182 | --Clicked Chicken -- | |
183 | currentMob = "Chicken" | |
184 | setCurrentMobData() | |
185 | rednet.send(Turtle, 7) | |
186 | -- 3rd Row -- | |
187 | elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 10) then | |
188 | --Clicked Blaze | |
189 | currentMob = "Blaze" | |
190 | setCurrentMobData() | |
191 | rednet.send(Turtle, 3) | |
192 | elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 10) then | |
193 | --Clicked None -- | |
194 | currentMob = "None" | |
195 | setCurrentMobData() | |
196 | rednet.send(Turtle, "Stop") | |
197 | ||
198 | -- 4th Row -- | |
199 | elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 12) then | |
200 | --Clicked Whisp -- | |
201 | currentMob = "Whisp" | |
202 | setCurrentMobData() | |
203 | rednet.send(Turtle, 4) | |
204 | elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 12) then | |
205 | --Clicked None -- | |
206 | currentMob = "None" | |
207 | setCurrentMobData() | |
208 | rednet.send(Turtle, "Stop") | |
209 | ||
210 | -- 5th Row -- | |
211 | elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 14) then | |
212 | --Clicked Cow -- | |
213 | currentMob = "Cow" | |
214 | setCurrentMobData() | |
215 | rednet.send(Turtle, 5) | |
216 | elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 14) then | |
217 | --Clicked None -- | |
218 | currentMob = "None" | |
219 | setCurrentMobData() | |
220 | rednet.send(Turtle, "Stop") | |
221 | end | |
222 | end | |
223 | ||
224 | --First time data setup -- | |
225 | setCurrentFarmStatusData() | |
226 | setCurrentSpawnerStatusData() | |
227 | setCurrentMobData() | |
228 | ||
229 | repeat | |
230 | event,p1,p2,p3 = os.pullEvent() | |
231 | ||
232 | if event == "monitor_touch" then | |
233 | mouseWidth = p2 | |
234 | mouseHeight = p3 | |
235 | checkClickPosition() | |
236 | end | |
237 | until event=="char" and p1==("x") |