Advertisement
GDragonArcher

tracking

Apr 8th, 2022 (edited)
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. --find and set up all peripherals
  2.  
  3. local detector = peripheral.find("playerDetector") -- Finds the peripheral if one is connected
  4. if detector == nil then error("playerDetector not found") end
  5.  
  6.  
  7.  
  8. while true do
  9.  
  10.     --setup all local variables
  11.     local line = 1 --current line number on monitor
  12.     local players = detector.getOnlinePlayers()
  13.     local numPlayers = #players
  14.     local i = 1
  15.  
  16.  
  17.     --remove GDragonArcher from the table
  18.     for k, v in pairs(players) do
  19.         if v == 'GDragonArcher' then
  20.             table.remove(players,k)
  21.             numPlayers = numPlayers - 1
  22.             break
  23.         end
  24.     end
  25.    
  26.    
  27.     --clear screen
  28.     term.clear()
  29.     term.setCursorPos(1,1)
  30.    
  31.    
  32.     --if I am alone
  33.     if numPlayers == 0 then
  34.  
  35.          write('You are the only one online')
  36.          print()
  37.          break
  38.     end
  39.  
  40.  
  41.    --print to screen
  42.     for i = 1, numPlayers do
  43.         local pos = detector.getPlayerPos(players[i]) --set what player you want the pos of
  44.        
  45.         if pos == nill then
  46.             print(players[i])
  47.             io.write("is in another dimension")
  48.             print()
  49.             print()
  50.         else
  51.             print(players[i]) --write player name
  52.             io.write("X:")
  53.             io.write(pos.x) --write the x pos of the player  
  54.             io.write(" Y:")
  55.             io.write(pos.y) --write the y pos of the player  
  56.             io.write(" Z:")
  57.             io.write(pos.z) --write the z pos of the player
  58.             print()
  59.             print()
  60.         end
  61.  
  62.         i = i + 1 --index i value
  63.     end
  64.     sleep(5)
  65.  
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement