View difference between Paste ID: 3YPw4mqN and dsDM4WzD
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,y)
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")
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")
44+
		drawBox(4,mh-scale*2,mw-4,6, green, mobs[1]..":  ON")
45
	end
46
47
end
48
49-
if spawners[0] == true then spawners[0] = false
49+
function toggle(i)
50-
else spawners[0] = true
50+
	if mobs[i] == true then mobs[i] = false
51
	else mobs[i] = true
52
end
53
54
function update()
55
	e, side, xp, yp = os.pullEvent("monitor_touch)
56
	if xp > 4 and xp < mw-4 then
57
		if yp < 10 and yp > 4 then
58
			toggle(0)
59
		elseif yp < mh-4 and yp > mh -10 then
60
			toggle(1)
61
		end 
62
	end
63
end
64
65
function init()
66
if peripheral.isPresent("bottom") then	
67
	mon = peripheral.wrap("bottom")
68
	mw, mh = mon.getSize()
69
	mon.setBackgroundColor(1)
70
	mon.setTextScale(scale)
71
	mon.clear()
72
	term.redirect(mon)
73
	foundMonitor = true
74
else
75
	foundMonitor = false
76
	print("Monitor not found - Aborting")
77
end
78
if foundMonitor == true then
79
	while true do 
80
		update()
81
		drawGUI()
82
		sleep(1)
83
	end
84
	term.restore()
85
end
86
end
87
88
init()