View difference between Paste ID: 1Uhqh422 and FSHU3enP
SHOW: | | - or go back to the newest paste.
1
--Variables --
2
mouseWidth = 0
3
mouseHeight = 0
4
5
currentMob = "None"
6
currentFarmStatus = "On  "
7
currentSpawnerStatus = "On  "
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(28,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(10,4)
57
	monitor.write(currentSpawnerStatus)
58
end
59
60
function setCurrentMobData()
61
62
	--Write first list of mobs
63
	
64
	monitor.setBackgroundColor((colors.red))
65
	
66
	if currentMob == "Enderman" then
67
		monitor.setBackgroundColor((colors.green))
68
	end
69
	monitor.setCursorPos(2,6)
70
	monitor.write("  Enderman  ")
71
	monitor.setBackgroundColor((colors.red))
72
73
	if currentMob == "Skeleton" then
74
		monitor.setBackgroundColor((colors.green))
75
	end
76
	monitor.setCursorPos(2,8)
77
	monitor.write("  Skeleton  ")
78
	monitor.setBackgroundColor((colors.red))
79
80
	if currentMob == "Blaze" then
81
		monitor.setBackgroundColor((colors.green))
82
	end
83
	monitor.setCursorPos(2,10)
84
	monitor.write("  Blaze     ")
85
	monitor.setBackgroundColor((colors.red))
86
87
	if currentMob == "Whisp" then
88
		monitor.setBackgroundColor((colors.green))
89
	end
90
	monitor.setCursorPos(2,12)
91
	monitor.write("  Whisp     ")
92
	monitor.setBackgroundColor((colors.red))
93
94
	if currentMob == "Cow" then
95
		monitor.setBackgroundColor((colors.green))
96
	end
97
	monitor.setCursorPos(2,14)
98
	monitor.write("  Cow       ")
99
	monitor.setBackgroundColor((colors.red))
100
101
	--Write second list of mobs
102
	if currentMob == "Ghast" then
103
		monitor.setBackgroundColor((colors.green))
104
	end
105
	monitor.setCursorPos(16,6)
106
	monitor.write("  Ghast     ")
107
	monitor.setBackgroundColor((colors.red))
108
	
109
	if currentMob == "Chicken" then
110
		monitor.setBackgroundColor((colors.green))
111
	end
112
	monitor.setCursorPos(16,8)
113
	monitor.write("  Chicken   ")
114
	monitor.setBackgroundColor((colors.red))
115
116
	monitor.setCursorPos(16,10)
117
	monitor.write("  None	   ")
118
	monitor.setBackgroundColor((colors.red))
119
120
	monitor.setCursorPos(16,12)
121
	monitor.write("  None	   ")
122
	monitor.setBackgroundColor((colors.red))
123
124
	if currentMob == "None" then
125
		monitor.setBackgroundColor((colors.green))
126
	end
127
	monitor.setCursorPos(16,14)
128
	monitor.write("  None	   ")
129
	monitor.setBackgroundColor((colors.red))
130
end
131
	
132
-- Perform clicked action --
133
function checkClickPosition()
134
	--Farm Status --
135
	if(mouseWidth > 27 and mouseWidth < 32 and mouseHeight == 4) thens
136
		--Clicked Status --
137
		if(currentFarmStatus == "On  ") then
138
			currentFarmStatus = "Off "
139
			redstone.setOutput("right", false)
140
		elseif(currentFarmStatus == "Off ") then
141
			currentFarmStatus = "On  "
142
			redstone.setOutput("right", true)
143
		end
144
		setCurrentFarmStatusData()
145
	end	
146
	--Spawner Status --
147-
	if(mouseWidth > 27 and mouseWidth < 32 and mouseHeight == 4) then
147+
148
		--Clicked Status --
149
		if(currentSpawnerStatus == "On  ") then
150
			currentSpawnerStatus = "Off "
151
			rednet.send(Turtle, "Off")	
152
		elseif(currentSpawnerStatus == "Off ") then
153
			currentSpawnerStatus = "On  "
154
			rednet.send(Turtle, "On")	
155
		end
156
		setCurrentSpawnerStatusData()
157
	end	
158
	-- 1st Row --
159
	if(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 6) then
160
		--Clicked Enderman --
161
		currentMob = "Enderman"
162
		setCurrentMobData()		
163
		rednet.send(Turtle, 1)	
164
	elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 6) then
165
		--Clicked Ghast--
166
		currentMob = "Ghast"
167
		setCurrentMobData()
168
	rednet.send(Turtle, 6)	
169
	-- 2nd Row --
170
	elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 8) then
171
		--Clicked Skeleton --
172
		currentMob = "Skeleton"
173
		setCurrentMobData()
174
		rednet.send(Turtle, 2)		
175
	elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 8) then
176
		--Clicked Chicken --
177
		currentMob = "Chicken"
178
		setCurrentMobData()
179
		rednet.send(Turtle, 7)	
180
	-- 3rd Row --
181
	elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 10) then
182
		--Clicked Blaze
183
		currentMob = "Blaze"
184
		setCurrentMobData()	
185
		rednet.send(Turtle, 3)	
186
	elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 10) then
187
		--Clicked None --
188
		currentMob = "None"
189
		setCurrentMobData()
190
		rednet.send(Turtle, "Stop")		
191
192
	-- 4th Row --
193
	elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 12) then
194
		--Clicked Whisp --
195
		currentMob = "Whisp"
196
		setCurrentMobData()	
197
		rednet.send(Turtle, 4)	
198
	elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 12) then
199
		--Clicked None --
200
		currentMob = "None"
201
		setCurrentMobData()
202
		rednet.send(Turtle, "Stop")	
203
204
	-- 5th Row --
205
	elseif(mouseWidth > 1 and mouseWidth < 13 and mouseHeight == 14) then
206
		--Clicked Cow --
207
		currentMob = "Cow"
208
		setCurrentMobData()
209
		rednet.send(Turtle, 5)		
210
	elseif(mouseWidth > 15 and mouseWidth < 27 and mouseHeight == 14) then
211
		--Clicked None --
212
		currentMob = "None"
213
		setCurrentMobData()
214
		rednet.send(Turtle, "Stop")	
215
	end
216
end
217
218
--First time data setup --
219
setCurrentMobData()
220
setCurrentFarmStatusData()
221
setCurrentSpawnerStatusData()
222
223
repeat
224
	event,p1,p2,p3 = os.pullEvent()
225
226
	if event == "monitor_touch" then
227
		mouseWidth = p2
228
		mouseHeight = p3
229
		checkClickPosition()
230
	end
231
until event=="char" and p1==("x")