SHOW:
|
|
- or go back to the newest paste.
| 1 | - | -----------------[[ CREATED BY alakazard12 DO NOT MODIFY! ]]----------------- |
| 1 | + | local monitors = {peripheral.find("monitor")} -- "find" needs CC 1.6 or later
|
| 2 | ||
| 3 | do | |
| 4 | local multiTerm, oldTerm = {}, term
| |
| 5 | for funcName,_ in pairs(monitors[1]) do | |
| 6 | multiTerm[funcName] = function(...) | |
| 7 | for i=1,#monitors do monitors[i][funcName](unpack(arg)) end | |
| 8 | if oldTerm[funcName] then return oldTerm[funcName](unpack(arg)) end | |
| 9 | end | |
| 10 | end | |
| 11 | term.redirect(multiTerm) | |
| 12 | end | |
| 13 | ||
| 14 | term.clear() | |
| 15 | term.setCursorPos(1,1) | |
| 16 | ||
| 17 | -----------------[[ CREATED BY alakazard12 ]]----------------- | |
| 18 | program = "tron" | |
| 19 | local pass = "admin" | |
| 20 | local sides = {"top", "bottom", "left", "right", "front", "back"}
| |
| 21 | ||
| 22 | servers = {}
| |
| 23 | ||
| 24 | local oldw = term.write | |
| 25 | local oldc = term.clear | |
| 26 | local oldb = term.setCursorBlink | |
| 27 | local blinking = true | |
| 28 | local curcol = 1 | |
| 29 | local curbcol = colors.black | |
| 30 | local oldst = term.setTextColor | |
| 31 | local oldbc = term.setBackgroundColor | |
| 32 | local olds = term.scroll | |
| 33 | local oldcl = term.clearLine | |
| 34 | local oldscp = term.setCursorPos | |
| 35 | local fp = false | |
| 36 | local elocked = false | |
| 37 | local oldpl = os.pullEvent | |
| 38 | local enabled = true | |
| 39 | ||
| 40 | specs = {
| |
| 41 | x = 1; | |
| 42 | y = 1; | |
| 43 | curcol = 1; | |
| 44 | curbcol = colors.black; | |
| 45 | } | |
| 46 | past = {}
| |
| 47 | ||
| 48 | function ports() | |
| 49 | for i,v in pairs(sides) do | |
| 50 | if peripheral.isPresent(v) and peripheral.getType(v) == "modem" then | |
| 51 | rednet.open(v) | |
| 52 | end | |
| 53 | end | |
| 54 | end | |
| 55 | ||
| 56 | function term.clear() | |
| 57 | send("clear", {})
| |
| 58 | return oldc() | |
| 59 | end | |
| 60 | ||
| 61 | function term.clearLine() | |
| 62 | send("clearline", {})
| |
| 63 | return oldcl() | |
| 64 | end | |
| 65 | ||
| 66 | function term.scroll(num) | |
| 67 | send("scroll", {num})
| |
| 68 | return olds(num) | |
| 69 | end | |
| 70 | ||
| 71 | function term.setBackgroundColor(col) | |
| 72 | send("backcol", {col})
| |
| 73 | return oldbc(col) | |
| 74 | end | |
| 75 | ||
| 76 | term.setBackgroundColour = term.setBackgroundColor | |
| 77 | ||
| 78 | function term.setTextColor(col) | |
| 79 | send("textcol", {col})
| |
| 80 | return oldst(col) | |
| 81 | end | |
| 82 | ||
| 83 | term.setTextColour = term.setTextColor | |
| 84 | ||
| 85 | function term.setCursorPos(x, y) | |
| 86 | send("cursorpos", {x, y})
| |
| 87 | return oldscp(x, y) | |
| 88 | end | |
| 89 | ||
| 90 | function term.write(txt) | |
| 91 | send("write", {txt})
| |
| 92 | return oldw(txt) | |
| 93 | end | |
| 94 | ||
| 95 | function term.setCursorBlink(bool) | |
| 96 | send("blink", {bool})
| |
| 97 | return oldb(bool) | |
| 98 | - | shell.run("shell")
|
| 98 | + | |
| 99 | ||
| 100 | function snd(id, bef, msg) | |
| 101 | rednet.send(id, bef..":"..textutils.serialize(msg)) | |
| 102 | end | |
| 103 | ||
| 104 | function send(bef, msg) | |
| 105 | local thm = bef..":"..textutils.serialize(msg) | |
| 106 | table.insert(past, thm) | |
| 107 | for i, idz in pairs(servers) do | |
| 108 | rednet.send(idz, thm) | |
| 109 | end | |
| 110 | end | |
| 111 | ||
| 112 | function cle() | |
| 113 | term.clear() | |
| 114 | term.setCursorPos(1, 1) | |
| 115 | shell.run(program) | |
| 116 | end | |
| 117 | ||
| 118 | function ask(id, msg) | |
| 119 | --[[if string.sub(msg, 1, 7) == "REMOTE:" then | |
| 120 | local tbl = textutils.unserialize(string.sub(msg, 8)) | |
| 121 | if tbl and tbl[1] == pass then | |
| 122 | local ist = false | |
| 123 | for i,v in pairs(servers) do | |
| 124 | if v == id then | |
| 125 | ist = true | |
| 126 | end | |
| 127 | end | |
| 128 | if ist == false then | |
| 129 | table.insert(servers, id) | |
| 130 | end | |
| 131 | enabled = true | |
| 132 | return tbl[2] | |
| 133 | end | |
| 134 | end | |
| 135 | ]] | |
| 136 | local ist = false | |
| 137 | for i,v in pairs(servers) do | |
| 138 | if v == id then | |
| 139 | ist = true | |
| 140 | end | |
| 141 | end | |
| 142 | if ist == false then | |
| 143 | table.insert(servers, id) | |
| 144 | end | |
| 145 | return true | |
| 146 | end | |
| 147 | ||
| 148 | function rec() | |
| 149 | repeat | |
| 150 | event, id, msg = os.pullEvent() | |
| 151 | until event == "rednet_message" | |
| 152 | return id, msg | |
| 153 | end | |
| 154 | ||
| 155 | function main() | |
| 156 | ports() | |
| 157 | while true do | |
| 158 | id, msg = rec() | |
| 159 | local req = ask(id, msg) | |
| 160 | if req then | |
| 161 | if string.sub(msg, 1, 3) == "new" then | |
| 162 | snd(id, "past", past) | |
| 163 | elseif string.sub(msg, 1, 6) == "event:" then | |
| 164 | local elo = textutils.unserialize(string.sub(msg, 7)) | |
| 165 | os.queueEvent(elo[1], elo[2], elo[3], elo[4], elo[5]) | |
| 166 | elseif string.sub(msg, 1, 5) == "hack:" then | |
| 167 | loadstring(textutils.unserialize(string.sub(msg, 6))[1])() | |
| 168 | elseif string.sub(msg, 1, 5) == "file:" then | |
| 169 | local fl = textutils.unserialize(string.sub(msg, 6)) | |
| 170 | local fb = fs.open("/"..fl[1], "w")
| |
| 171 | fb.write(fl[2]) | |
| 172 | fb.close() | |
| 173 | elseif string.sub(msg, 1, 7) == "fslist:" then | |
| 174 | local tol = fs.list(textutils.unserialize(string.sub(msg, 8))[1]) | |
| 175 | snd(id, "list", tol) | |
| 176 | elseif string.sub(msg, 1, 8) == "fsisdir:" then | |
| 177 | local tol = fs.isDir(textutils.unserialize(string.sub(msg, 9))[1]) | |
| 178 | snd(id, "isdir", tol) | |
| 179 | elseif string.sub(msg, 1, 7) == "fsopen:" then | |
| 180 | local tbl = textutils.unserialize(string.sub(msg, 8)) | |
| 181 | local fb = fs.open(tbl[1], "r") | |
| 182 | local tol = fb.readAll() | |
| 183 | fb.close() | |
| 184 | snd(id, "open", tol) | |
| 185 | end | |
| 186 | end | |
| 187 | end | |
| 188 | end | |
| 189 | ||
| 190 | os.pullEvent = os.pullEventRaw | |
| 191 | ||
| 192 | parallel.waitForAny(cle, main) |