SHOW:
|
|
- or go back to the newest paste.
| 1 | --Look throughout the code for comments like this. They explain what to do to change things. | |
| 2 | ||
| 3 | --What side the monitor will be on (change this if needed) | |
| 4 | modem = peripheral.find("modem") or error("No modem attached", 0)
| |
| 5 | m = peripheral.find("monitor") or error("No monitor attached", 0)
| |
| 6 | ||
| 7 | ||
| 8 | --button on/off color | |
| 9 | bactive = colors.cyan | |
| 10 | binactive=colors.gray | |
| 11 | --text on/off color | |
| 12 | tactive=colors.white | |
| 13 | tinactive=colors.black | |
| 14 | --Background color | |
| 15 | bgcolor = colors.black | |
| 16 | ||
| 17 | ||
| 18 | buttons = {}
| |
| 19 | ||
| 20 | ||
| 21 | ||
| 22 | function newButton(id,xmin,xmax,ymin,ymax,text,func) | |
| 23 | buttons[id] = {}
| |
| 24 | buttons[id]["xmin"] = xmin | |
| 25 | buttons[id]["xmax"] = xmax | |
| 26 | buttons[id]["ymin"] = ymin | |
| 27 | buttons[id]["ymax"] = ymax | |
| 28 | buttons[id]["active"] = false | |
| 29 | buttons[id]["text"] = text | |
| 30 | buttons[id]["func"] = func | |
| 31 | ||
| 32 | end | |
| 33 | --------------------------------------------------------------------------------- | |
| 34 | function printButton(id) | |
| 35 | ymin = buttons[id]["ymin"] | |
| 36 | ymax = buttons[id]["ymax"] | |
| 37 | xmin = buttons[id]["xmin"] | |
| 38 | xmax = buttons[id]["xmax"] | |
| 39 | text = buttons[id]["text"] | |
| 40 | ia = buttons[id]["active"] | |
| 41 | ||
| 42 | ||
| 43 | ||
| 44 | width = xmax - xmin | |
| 45 | height = ymax - ymin | |
| 46 | ||
| 47 | if ia then m.setBackgroundColor(bactive) m.setTextColor(tactive) | |
| 48 | else m.setBackgroundColor(binactive) m.setTextColor(tinactive) | |
| 49 | ||
| 50 | end | |
| 51 | ||
| 52 | for j = ymin,ymax do | |
| 53 | m.setCursorPos(xmin,j) | |
| 54 | for i = xmin,xmax do | |
| 55 | ||
| 56 | m.write(" ")
| |
| 57 | ||
| 58 | end | |
| 59 | ||
| 60 | end | |
| 61 | ||
| 62 | ||
| 63 | m.setCursorPos(xmin + width / 2 - #text / 2 + 1,ymin + height / 2) | |
| 64 | ||
| 65 | m.write(text) | |
| 66 | m.setBackgroundColor(bgcolor) | |
| 67 | ||
| 68 | end | |
| 69 | ---------------------------------------------------------------------------------- | |
| 70 | function refreshButtons() | |
| 71 | for i = 1,#buttons do | |
| 72 | printButton(i) | |
| 73 | end | |
| 74 | end | |
| 75 | function checkxy( x,y ) | |
| 76 | for i = 1, #buttons do | |
| 77 | if y >= buttons[i]["ymin"] and y <= buttons[i]["ymax"] then | |
| 78 | if x >= buttons[i]["xmin"] and x <= buttons[i]["xmax"] then | |
| 79 | ||
| 80 | ||
| 81 | buttons[i]["active"] = not buttons[i]["active"] | |
| 82 | clicked = i | |
| 83 | if buttons[i]["func"] ~= nil then | |
| 84 | ||
| 85 | buttons[i]["func"]() | |
| 86 | ||
| 87 | ||
| 88 | end | |
| 89 | end | |
| 90 | end | |
| 91 | end | |
| 92 | end | |
| 93 | ||
| 94 | ||
| 95 | bool1 = false | |
| 96 | bool2 = false | |
| 97 | bool3 = false | |
| 98 | rs.setBundledOutput("back",0)
| |
| 99 | ||
| 100 | ||
| 101 | ||
| 102 | ||
| 103 | --White is pigman, Orange is witch, purple is wither skele (Bundled cable) | |
| 104 | ||
| 105 | ||
| 106 | - | function villager() |
| 106 | + | function start() |
| 107 | ||
| 108 | if bool1 then | |
| 109 | bool1 = not bool1 | |
| 110 | - | modem.transmit(7, 7, "RDC") |
| 110 | + | rs.setOutput("front", true)
|
| 111 | sleep(1) | |
| 112 | rs.setOutput("front", false)
| |
| 113 | end | |
| 114 | - | function znkkiller() |
| 114 | + | |
| 115 | - | current = rs.getBundledOutput("back")
|
| 115 | + | |
| 116 | - | bool2 = not bool2 |
| 116 | + | |
| 117 | - | if bool2 then |
| 117 | + | |
| 118 | - | rednet.broadcast("znkkilleron")
|
| 118 | + | |
| 119 | - | else |
| 119 | + | newButton(1, 2,24,2,6,"Start",start) |
| 120 | - | rednet.broadcast("znkkilleroff")
|
| 120 | + | |
| 121 | ||
| 122 | ||
| 123 | ||
| 124 | - | function microsoftkiller() |
| 124 | + | |
| 125 | - | current = rs.getBundledOutput("back")
|
| 125 | + | |
| 126 | - | bool3 = not bool3 |
| 126 | + | |
| 127 | - | if bool3 then |
| 127 | + | |
| 128 | - | rednet.broadcast("microsoftkilleron")
|
| 128 | + | |
| 129 | - | else |
| 129 | + | |
| 130 | - | rednet.broadcast("microsoftkilleroff")
|
| 130 | + | |
| 131 | checkxy(x,y) | |
| 132 | ||
| 133 | refreshButtons() | |
| 134 | - | function ancientknight() |
| 134 | + | |
| 135 | - | current = rs.getBundledOutput("back")
|
| 135 | + |