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" |
| 11 | + | mobs[0] = "CREEPER" |
| 12 | - | mobs[1] = "MOB2" |
| 12 | + | mobs[1] = "BLAZE" |
| 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 | rednet.broadcast(tostring(i)) | |
| 54 | end | |
| 55 | ||
| 56 | function update() | |
| 57 | e, side, xp, yp = os.pullEvent("monitor_touch")
| |
| 58 | mon.setCursorPos(1,1) | |
| 59 | if xp > 1 and xp < 19 then | |
| 60 | --possible over | |
| 61 | if yp < 6 then | |
| 62 | toggle(0) | |
| 63 | elseif yp >=6 then | |
| 64 | toggle(1) | |
| 65 | end | |
| 66 | end | |
| 67 | end | |
| 68 | ||
| 69 | function init() | |
| 70 | - | if peripheral.isPresent("bottom") then
|
| 70 | + | if peripheral.isPresent("top") then
|
| 71 | - | mon = peripheral.wrap("bottom")
|
| 71 | + | mon = peripheral.wrap("top")
|
| 72 | mw, mh = mon.getSize() | |
| 73 | mon.setBackgroundColor(32768) | |
| 74 | mon.setTextScale(scale) | |
| 75 | mon.clear() | |
| 76 | term.redirect(mon) | |
| 77 | foundMonitor = true | |
| 78 | else | |
| 79 | foundMonitor = false | |
| 80 | print("Monitor not found - Aborting")
| |
| 81 | end | |
| 82 | rednet.open("right")
| |
| 83 | ||
| 84 | if foundMonitor == true then | |
| 85 | while true do | |
| 86 | update() | |
| 87 | drawGUI() | |
| 88 | sleep(0.5) | |
| 89 | end | |
| 90 | term.restore() | |
| 91 | end | |
| 92 | end | |
| 93 | ||
| 94 | init() |