Advertisement
ccraftersanonmoose

AR Goggles Test

Mar 18th, 2023 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | Gaming | 0 0
  1. -- Name the peripherals for simplicity
  2. local arc = peripheral.wrap("arController_0")
  3. local pd = peripheral.wrap("right")
  4.  
  5. -- Set up the display parameters
  6. local text_color = 255  -- White text
  7. local text_scale = 2
  8. local text_offset_x = 10
  9. local text_offset_y = 10
  10.  
  11. -- Get the username of the player running the script
  12. local player_name = os.getComputerLabel()
  13.  
  14. function display_hud()
  15.     -- Find the player with the same name as the player running the script
  16.     local online_players = pd.getOnlinePlayers()
  17.     local player_coords
  18.     for _, player in ipairs(online_players) do
  19.         if player.username == player_name then
  20.             player_coords = player.pos
  21.             break
  22.         end
  23.     end
  24.    
  25.     -- Format the coordinates as a string
  26.     local x = math.floor(player_coords.x)
  27.     local y = math.floor(player_coords.y)
  28.     local z = math.floor(player_coords.z)
  29.     local coord_str = "X: " .. x .. ", Y: " .. y .. ", Z: " .. z
  30.    
  31.     -- Clear the AR display
  32.     arc.clear()
  33.    
  34.     -- Draw the coordinates on the display
  35.     arc.drawString(coord_str, text_offset_x, text_offset_y, text_color, text_scale)
  36. end
  37.  
  38. -- Loop to update the display at regular intervals
  39. while true do
  40.     display_hud()
  41.     sleep(0.5)
  42. end
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement