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 spawners[i] == true then spawners[i] = false | |
| 51 | else spawners[i] = true | |
| 52 | end | |
| 53 | end | |
| 54 | ||
| 55 | function update() | |
| 56 | e, side, xp, yp = os.pullEvent("monitor_touch")
| |
| 57 | - | if xp > 4 and xp < mw-4 then |
| 57 | + | print(xp .. " " .. yp) |
| 58 | - | if yp < 10 and yp > 4 then |
| 58 | + | |
| 59 | - | toggle(0) |
| 59 | + | |
| 60 | - | elseif yp < mh-4 and yp > mh -10 then |
| 60 | + | |
| 61 | - | toggle(1) |
| 61 | + | |
| 62 | - | end |
| 62 | + | |
| 63 | mw, mh = mon.getSize() | |
| 64 | mon.setBackgroundColor(1) | |
| 65 | mon.setTextScale(scale) | |
| 66 | mon.clear() | |
| 67 | term.redirect(mon) | |
| 68 | foundMonitor = true | |
| 69 | else | |
| 70 | foundMonitor = false | |
| 71 | print("Monitor not found - Aborting")
| |
| 72 | end | |
| 73 | if foundMonitor == true then | |
| 74 | while true do | |
| 75 | update() | |
| 76 | drawGUI() | |
| 77 | sleep(0.5) | |
| 78 | end | |
| 79 | term.restore() | |
| 80 | end | |
| 81 | end | |
| 82 | ||
| 83 | - | sleep(1) |
| 83 | + |