Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function startup()
- shell.run("getNames")
- shell.run("savePos")
- curListLen = rs.getAnalogInput("top")
- file = fs.open("curPlayers","r")
- i=0
- playerNumbers = {}
- playerNames = {}
- repeat
- line = file.readLine()
- if line ~= nil then
- playerNumbers[line] = i
- playerNames[i] = line
- end
- i=i+1
- until line == nil
- saveTimer = os.startTimer(18000)
- end
- function main()
- while true do
- info1,info2,info3,info4 = os.pullEvent()
- if rs.getAnalogInput("top") ~= curListLen then
- os.reboot()
- end
- if info1 == "timer" and info2 == saveTimer then
- shell.run("savePos")
- saveTimer = os.startTimer(18000)
- end
- if info1 == "rednet_message" then
- if type(info3) == "table" then
- if info3["action"] == "getPos" then
- shell.run("getPos " .. playerNumbers[info3["player"]])
- file = fs.open("curPlayerPos","r")
- rednet.send(info2,{["action"]="sendingPos",["x"]=file.readLine(),["y"]=file.readLine(),["z"]=file.readLine()})
- end
- end
- if info3 == "getPlayers" then
- rednet.send(info2,{["action"]="sendingPlayers",["players"]=playerNames})
- end
- end
- end
- end
- startup()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement