SHOW:
|
|
- or go back to the newest paste.
| 1 | file = fs.open("curPlayers","r")
| |
| 2 | playerNames = {}
| |
| 3 | i=0 | |
| 4 | repeat | |
| 5 | i=i+1 | |
| 6 | line = file.readLine() | |
| 7 | playerNames[i] = line | |
| 8 | until line == nil | |
| 9 | playerNames[i] = nil | |
| 10 | file.close() | |
| 11 | ||
| 12 | ||
| 13 | ||
| 14 | rednet.open("right")
| |
| 15 | ||
| 16 | playerPos = {}
| |
| 17 | for k,v in pairs(playerNames) do | |
| 18 | rednet.send(939,k-1) | |
| 19 | rednet.send(939,"start") | |
| 20 | sleep(0.4) | |
| 21 | playerPos[k] = {}
| |
| 22 | rednet.send(936,"start") | |
| 23 | rednet.send(937,"start") | |
| 24 | rednet.send(938,"start") | |
| 25 | rednet.send(939,"stop") | |
| 26 | ||
| 27 | os.startTimer(0.05) | |
| 28 | repeat | |
| 29 | info1,info2,info3,info4 = os.pullEvent() | |
| 30 | if info1 == "rednet_message" and type(info3) == "table" then | |
| 31 | if info3["action"] == "sendingX" then | |
| 32 | playerPos[k]["x"] = info3["x"] | |
| 33 | end | |
| 34 | ||
| 35 | if info3["action"] == "sendingY" then | |
| 36 | playerPos[k]["y"] = info3["y"] | |
| 37 | end | |
| 38 | ||
| 39 | if info3["action"] == "sendingZ" then | |
| 40 | playerPos[k]["z"] = info3["z"] | |
| 41 | end | |
| 42 | end | |
| 43 | until info1 == "timer" | |
| 44 | rednet.send(939,"stop") | |
| 45 | sleep(0.2) | |
| 46 | end | |
| 47 | ||
| 48 | rednet.send(939,0) | |
| 49 | ||
| 50 | ||
| 51 | ||
| 52 | for k,v in pairs(playerNames) do | |
| 53 | print(playerNames[k]) | |
| 54 | file = fs.open("playerPos/" .. os.day("local") .. "/" .. (math.floor(os.time("local")*1000)/1000) .. "/" .. playerNames[k],"w")
| |
| 55 | ||
| 56 | file.writeLine(playerPos[k]["x"]) | |
| 57 | file.writeLine(playerPos[k]["y"]) | |
| 58 | file.writeLine(playerPos[k]["z"]) | |
| 59 | ||
| 60 | file.flush() | |
| 61 | file.close() | |
| 62 | end | |
| 63 | ||
| 64 | ||
| 65 | rednet.send(941,"ping") | |
| 66 | os.startTimer(0.1) | |
| 67 | repeat | |
| 68 | info1,info2,info3,info4 = os.pullEvent() | |
| 69 | until info3 == "pong" or info1 == "timer" | |
| 70 | ||
| 71 | ||
| 72 | if info3 == "pong" then | |
| 73 | ||
| 74 | posData={}
| |
| 75 | i=0 | |
| 76 | for k1,v1 in pairs(fs.list("playerPos")) do
| |
| 77 | curDay = fs.list("playerPos")[k1]
| |
| 78 | ||
| 79 | for k2,v2 in pairs(fs.list("playerPos/"..curDay)) do
| |
| 80 | curTime = fs.list("playerPos/"..curDay)[k2]
| |
| 81 | ||
| 82 | if fs.isDir("playerPos/"..curDay.."/"..curTime) then
| |
| 83 | for k3,v3 in pairs(fs.list("playerPos/"..curDay.."/"..curTime)) do
| |
| 84 | curPlayer = fs.list("playerPos/"..curDay.."/"..curTime)[k3]
| |
| 85 | ||
| 86 | if fs.exists("playerPos/"..curDay.."/"..curTime.."/"..curPlayer) then
| |
| 87 | i=i+1 | |
| 88 | file = fs.open("playerPos/"..curDay.."/"..curTime.."/"..curPlayer,"r")
| |
| 89 | curPosData = {}
| |
| 90 | curPosData["day"]=curDay | |
| 91 | curPosData["time"]=curTime | |
| 92 | curPosData["player"]=curPlayer | |
| 93 | curPosData["x"]=file.readLine() | |
| 94 | curPosData["y"]=file.readLine() | |
| 95 | curPosData["z"]=file.readLine() | |
| 96 | file.close() | |
| 97 | posData[i] = curPosData | |
| 98 | end | |
| 99 | ||
| 100 | end | |
| 101 | ||
| 102 | end | |
| 103 | end | |
| 104 | end | |
| 105 | rednet.send(info2,{["action"]="sendingPosData",["player"]=info3["player"],["posData"]=posData})
| |
| 106 | fs.delete("playerPos")
| |
| 107 | end | |
| 108 | ||
| 109 | ||
| 110 | ||
| 111 |