Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foundMonitor = false
- mw, mh = 0
- spawners = {}
- spawners[0] = false
- spawners[1] = true
- red = 16384
- green = 32
- scale = 2
- mobs = {}
- mobs[0] = "BLAZE"
- mobs[1] = "MOB2"
- function drawBox(x,y,w,h,c, label)
- x = x/scale
- y = y/scale
- w = w/scale
- h = h/scale
- i = x
- _w = w + x
- _h = h+y
- while i < _w do
- j = y
- while j < _h do
- paintutils.drawPixel(i,j,c)
- j = j+1
- end
- i = i+1
- end
- mon.setCursorPos(x +w/2 - #label/2, y+1)
- mon.write(label)
- end
- function drawGUI()
- mon.setCursorPos(1,1)
- if spawners[0] == false then
- drawBox(4,scale*2,mw-4,6, red, mobs[0]..": OFF")
- else
- drawBox(4,scale*2,mw-4,6, green, mobs[0]..": ON")
- end
- if spawners[1] == false then
- drawBox(4,mh-scale*2,mw-4,6, red, mobs[1]..": OFF")
- else
- drawBox(4,mh-scale*2,mw-4,6, green, mobs[1]..": ON")
- end
- end
- function toggle(i)
- if mobs[i] == true then mobs[i] = false
- else mobs[i] = true
- end
- function update()
- e, side, xp, yp = os.pullEvent("monitor_touch)
- if xp > 4 and xp < mw-4 then
- if yp < 10 and yp > 4 then
- toggle(0)
- elseif yp < mh-4 and yp > mh -10 then
- toggle(1)
- end
- end
- end
- function init()
- if peripheral.isPresent("bottom") then
- mon = peripheral.wrap("bottom")
- mw, mh = mon.getSize()
- mon.setBackgroundColor(1)
- mon.setTextScale(scale)
- mon.clear()
- term.redirect(mon)
- foundMonitor = true
- else
- foundMonitor = false
- print("Monitor not found - Aborting")
- end
- if foundMonitor == true then
- while true do
- update()
- drawGUI()
- sleep(1)
- end
- term.restore()
- end
- end
- init()
Advertisement
Add Comment
Please, Sign In to add comment