Advertisement
Chaos_Cash

computer playerdata

Sep 9th, 2024 (edited)
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.47 KB | None | 0 0
  1. function startup()
  2.  
  3. shell.run("getNames")
  4. shell.run("savePos")
  5.  
  6. curListLen = rs.getAnalogInput("top")
  7.  
  8. file = fs.open("curPlayers","r")
  9.  
  10. i=0
  11. playerNumbers = {}
  12. playerNames = {}
  13.     repeat
  14.     line = file.readLine()
  15.         if line ~= nil then
  16.         playerNumbers[line] = i
  17.         playerNames[i] = line
  18.         end
  19.     i=i+1
  20.     until line == nil
  21.  
  22. saveTimer = os.startTimer(18000)
  23. end
  24.  
  25.  
  26. function main()
  27.  
  28.     while true do
  29.    
  30.     info1,info2,info3,info4 = os.pullEvent()
  31.    
  32.    
  33.         if rs.getAnalogInput("top") ~= curListLen then
  34.         os.reboot()
  35.         end
  36.        
  37.        
  38.         if info1 == "timer" and info2 == saveTimer then
  39.         shell.run("savePos")
  40.         saveTimer = os.startTimer(18000)
  41.         end
  42.        
  43.        
  44.         if info1 == "rednet_message" then
  45.        
  46.             if type(info3) == "table" then
  47.            
  48.            
  49.                 if info3["action"] == "getPos" then
  50.                 shell.run("getPos " .. playerNumbers[info3["player"]])
  51.                 file = fs.open("curPlayerPos","r")
  52.                 rednet.send(info2,{["action"]="sendingPos",["x"]=file.readLine(),["y"]=file.readLine(),["z"]=file.readLine()})
  53.                 end
  54.                
  55.  
  56.             end
  57.            
  58.             if info3 == "getPlayers" then
  59.             rednet.send(info2,{["action"]="sendingPlayers",["players"]=playerNames})
  60.             end
  61.        
  62.         end
  63.    
  64.     end
  65.  
  66. end
  67.  
  68.  
  69. startup()
  70. main()
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement