Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Name the peripherals for simplicity
- local arc = peripheral.wrap("arController_0")
- local pd = peripheral.wrap("right")
- -- Set up the display parameters
- local text_color = 255 -- White text
- local text_scale = 2
- local text_offset_x = 10
- local text_offset_y = 10
- -- Get the username of the player running the script
- local player_name = os.getComputerLabel()
- function display_hud()
- -- Find the player with the same name as the player running the script
- local online_players = pd.getOnlinePlayers()
- local player_coords
- for _, player in ipairs(online_players) do
- if player.username == player_name then
- player_coords = player.pos
- break
- end
- end
- -- Format the coordinates as a string
- local x = math.floor(player_coords.x)
- local y = math.floor(player_coords.y)
- local z = math.floor(player_coords.z)
- local coord_str = "X: " .. x .. ", Y: " .. y .. ", Z: " .. z
- -- Clear the AR display
- arc.clear()
- -- Draw the coordinates on the display
- arc.drawString(coord_str, text_offset_x, text_offset_y, text_color, text_scale)
- end
- -- Loop to update the display at regular intervals
- while true do
- display_hud()
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement