View difference between Paste ID: 6TKRZdLz and 3YPw4mqN
SHOW: | | - or go back to the newest paste.
1
foundMonitor = false
2
mw, mh = 0
3
spawners = {}
4
spawners[0] = false
5
spawners[1] = true
6
red = 16384
7
green = 32
8
scale = 2
9
10
mobs = {}
11
mobs[0] = "BLAZE"
12
mobs[1] = "MOB2"
13
function drawBox(x,y,w,h,c, label)
14
	x = x/scale
15
	y = y/scale
16
	w = w/scale
17
	h = h/scale
18
	
19
        i = x
20
	_w = w + x
21
	_h = h+y
22
	while i < _w do
23
	j = y
24
		while j < _h do
25
			paintutils.drawPixel(i,j,c)
26
			j = j+1
27
		end
28
	i = i+1
29
	end
30
	mon.setCursorPos(x +w/2 - #label/2, y+1)
31
	mon.write(label)
32
end
33
function drawGUI()
34
	mon.setCursorPos(1,1)
35
	if spawners[0] == false then
36
		drawBox(4,scale*2,mw-4,6, red, mobs[0]..": OFF")
37
	else
38
		drawBox(4,scale*2,mw-4,6, green, mobs[0]..":  ON")
39
	end
40
41
	if spawners[1] == false then
42
		drawBox(4,mh-scale*2,mw-4,6, red, mobs[1]..": OFF")
43
	else
44
		drawBox(4,mh-scale*2,mw-4,6, green, mobs[1]..":  ON")
45
	end
46
47
end
48
49
function toggle(i)
50-
	if mobs[i] == true then mobs[i] = false
50+
	if spawners[i] == true then spawners[i] = false
51-
	else mobs[i] = true
51+
	else spawners[i] = true
52
	end
53
end
54
55-
	e, side, xp, yp = os.pullEvent("monitor_touch)
55+
56
	e, side, xp, yp = os.pullEvent("monitor_touch")
57
	if xp > 4 and xp < mw-4 then
58
		if yp < 10 and yp > 4 then
59
			toggle(0)
60
		elseif yp < mh-4 and yp > mh -10 then
61
			toggle(1)
62
		end 
63
	end
64
end
65
66
function init()
67
if peripheral.isPresent("bottom") then	
68
	mon = peripheral.wrap("bottom")
69
	mw, mh = mon.getSize()
70
	mon.setBackgroundColor(1)
71
	mon.setTextScale(scale)
72
	mon.clear()
73
	term.redirect(mon)
74
	foundMonitor = true
75
else
76
	foundMonitor = false
77
	print("Monitor not found - Aborting")
78
end
79
if foundMonitor == true then
80
	while true do 
81
		update()
82
		drawGUI()
83
		sleep(1)
84
	end
85
	term.restore()
86
end
87
end
88
89
init()