SHOW:
|
|
- or go back to the newest paste.
| 1 | local tbl = { a = "top", b = "bottom", c = "left", d = "right", f = "front", g = "back" }
| |
| 2 | table.foreach(tbl, | |
| 3 | function(k, v) | |
| 4 | if peripheral.isPresent(v) then | |
| 5 | if peripheral.getType(v) == "modem" then | |
| 6 | print("open modem")
| |
| 7 | rednet.open(v) | |
| 8 | end | |
| 9 | end | |
| 10 | end) | |
| 11 | shell.run("clear")
| |
| 12 | print("Playerlist:")
| |
| 13 | print("")
| |
| 14 | pid=1 | |
| 15 | if not fs.exists("player"..pid) then
| |
| 16 | file=fs.open("player"..pid,"w")
| |
| 17 | name="M3veronMast3r" | |
| 18 | file.writeLine(name) | |
| 19 | file.close() | |
| 20 | end | |
| 21 | while fs.exists("player"..pid) do
| |
| 22 | pidt=pid | |
| 23 | pid=1 | |
| 24 | while fs.exists("player"..pid) do
| |
| 25 | pid=pid+1 | |
| 26 | end | |
| 27 | pid=pid-1 | |
| 28 | pidz=pid | |
| 29 | pid=pidt | |
| 30 | file=fs.open("player"..pid,"r")
| |
| 31 | name=file.readLine() | |
| 32 | file.close() | |
| 33 | if fs.exists("players") then
| |
| 34 | file=fs.open("players","r")
| |
| 35 | ppidz=tonumber(file.readLine()) | |
| 36 | if ppidz > pidz then | |
| 37 | pidz = ppidz | |
| 38 | end | |
| 39 | file.close() | |
| 40 | end | |
| 41 | pidx=pid | |
| 42 | online=false | |
| 43 | id, text = rednet.receive() | |
| 44 | if id == 39 then | |
| 45 | table.foreach(text, | |
| 46 | function(k, v) | |
| 47 | if v == name then | |
| 48 | online = true | |
| 49 | if not fs.exists(name) then | |
| 50 | file=fs.open(name,"w") | |
| 51 | Last=1 | |
| 52 | file.writeLine(Last) | |
| 53 | file.close() | |
| 54 | end | |
| 55 | end | |
| 56 | if not fs.exists(v) then | |
| 57 | t=1 | |
| 58 | for i=1,pidz do | |
| 59 | file=fs.open("player"..pidz,"r")
| |
| 60 | if file.readLine == v then | |
| 61 | file.close() | |
| 62 | file=fs.open(v,"w") | |
| 63 | Last=1 | |
| 64 | file.writeLine(Last) | |
| 65 | file.close() | |
| 66 | t=0 | |
| 67 | else | |
| 68 | file.close() | |
| 69 | if i == pidz then | |
| 70 | if t > 0 then | |
| 71 | pidt=pid | |
| 72 | pid=pidz | |
| 73 | pid=pid+1 | |
| 74 | file=fs.open("player"..pid,"w")
| |
| 75 | file.writeLine(v) | |
| 76 | pidz=pidz+1 | |
| 77 | pid=pidt | |
| 78 | file.close() | |
| 79 | file=fs.open(v,"w") | |
| 80 | Last=1 | |
| 81 | file.writeLine(Last) | |
| 82 | file.close() | |
| 83 | t=0 | |
| 84 | end | |
| 85 | end | |
| 86 | end | |
| 87 | end | |
| 88 | end | |
| 89 | end) | |
| 90 | end | |
| 91 | if not online == true then | |
| 92 | online = false | |
| 93 | end | |
| 94 | if not fs.exists(name) then | |
| 95 | file=fs.open(name,"w") | |
| 96 | last=1 | |
| 97 | file.writeLine(last) | |
| 98 | file.close() | |
| 99 | end | |
| 100 | if online == true then | |
| 101 | file=fs.open(name,"w") | |
| 102 | - | last=0 |
| 102 | + | lastd=os.day() |
| 103 | file.writeLine(lastd) | |
| 104 | lastz=os.time() | |
| 105 | file.writeLine(lastz) | |
| 106 | file.close() | |
| 107 | end | |
| 108 | - | last=file.readLine() |
| 108 | + | |
| 109 | s=0 | |
| 110 | - | last=last+1 |
| 110 | + | |
| 111 | nD=tonumber(file.readLine()) | |
| 112 | nT=tonumber(file.readLine()) | |
| 113 | file.close() | |
| 114 | - | seconds=last |
| 114 | + | if nT > os.time() then |
| 115 | t=0 | |
| 116 | while nT < 24 do | |
| 117 | nT=nT+0.001 | |
| 118 | - | while seconds > 60 do |
| 118 | + | t=t+1 |
| 119 | if t == 20 then | |
| 120 | s=s+1 | |
| 121 | t=0 | |
| 122 | - | while minutes > 60 do |
| 122 | + | |
| 123 | end | |
| 124 | nT=0 | |
| 125 | end | |
| 126 | - | while hours > 24 do |
| 126 | + | t=0 |
| 127 | while nT < os.time() do | |
| 128 | nT=nT+0.001 | |
| 129 | t=t+1 | |
| 130 | if t == 20 then | |
| 131 | s=s+1 | |
| 132 | t=0 | |
| 133 | end | |
| 134 | end | |
| 135 | day=os.day()-nD | |
| 136 | s=s+day*1200 | |
| 137 | seconds=s | |
| 138 | minutes=0 | |
| 139 | hours=0 | |
| 140 | days=0 | |
| 141 | while seconds > 59 do | |
| 142 | minutes=minutes+1 | |
| 143 | seconds=seconds-60 | |
| 144 | end | |
| 145 | while minutes > 59 do | |
| 146 | hours=hours+1 | |
| 147 | minutes=minutes-60 | |
| 148 | end | |
| 149 | while hours > 23 do | |
| 150 | days=days+1 | |
| 151 | hours=hours-24 | |
| 152 | end | |
| 153 | end | |
| 154 | if online == true then | |
| 155 | pid=pid+2 | |
| 156 | term.setCursorPos( 1,pid ) | |
| 157 | print(name) | |
| 158 | term.setCursorPos( 16,pid ) | |
| 159 | local w,h = term.getSize() | |
| 160 | for i=16,w do | |
| 161 | write(" ")
| |
| 162 | end | |
| 163 | term.setCursorPos( 20,pid ) | |
| 164 | print("Online")
| |
| 165 | pid=pid-2 | |
| 166 | else | |
| 167 | pid=pid+2 | |
| 168 | term.setCursorPos( 1,pid ) | |
| 169 | print(name) | |
| 170 | term.setCursorPos( 16,pid ) | |
| 171 | local w,h = term.getSize() | |
| 172 | for i=16,w do | |
| 173 | - | sleep(0.5) |
| 173 | + | |
| 174 | end | |
| 175 | if w < 30 then | |
| 176 | term.setCursorPos( 16,pid ) | |
| 177 | if days < 1 then | |
| 178 | print(hours.."h "..minutes.."m "..seconds.."s ago") | |
| 179 | else | |
| 180 | print(days.."d "..hours.."h "..minutes.."m") | |
| 181 | end | |
| 182 | else | |
| 183 | term.setCursorPos( 20,pid ) | |
| 184 | print(days.."d "..hours.."h "..minutes.."m "..seconds.."s ago") | |
| 185 | end | |
| 186 | pid=pid-2 | |
| 187 | end | |
| 188 | pid=pid+1 | |
| 189 | if not fs.exists("player"..pid) then
| |
| 190 | pid=1 | |
| 191 | print("")
| |
| 192 | print("Players: "..pidz)
| |
| 193 | file=fs.open("players","w")
| |
| 194 | file.writeLine(pidz) | |
| 195 | file.close() | |
| 196 | end | |
| 197 | end | |
| 198 | pid=pid-1 |