yeeeeeeeeeeeee

CORDS

Mar 27th, 2025
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. -- Wrap peripherals
  2. local monitor = peripheral.wrap("top")
  3. local silo = peripheral.wrap("left")
  4. local playerDetector = peripheral.wrap("right")
  5.  
  6. -- Setup the monitor
  7. monitor.clear()
  8. monitor.setTextScale(1)
  9. monitor.setTextColor(colors.white)
  10. monitor.setBackgroundColor(colors.black)
  11.  
  12. -- Monitor dimensions
  13. local width, height = monitor.getSize()
  14.  
  15. -- Table to store player names and their displayed positions
  16. local playerDisplay = {}
  17. local selectedPlayer = nil -- Store the selected player's name
  18.  
  19. -- Check if the player detector supports coordinate retrieval
  20. local hasGetPlayerCoords = playerDetector and playerDetector.getPlayerPos ~= nil
  21.  
  22. -- Helper function to update the monitor
  23. local function updateMonitor(players)
  24.     monitor.clear()
  25.     playerDisplay = {} -- Reset playerDisplay table
  26.    
  27.     if #players > 0 then
  28.         monitor.setCursorPos(1, 1)
  29.         monitor.setTextColor(colors.cyan)
  30.         monitor.write("Players Nearby:")
  31.  
  32.         for i, player in ipairs(players) do
  33.             local x = 2
  34.             local y = i + 2
  35.             playerDisplay[i] = { name = player, posX = x, posY = y }
  36.             monitor.setCursorPos(x, y)
  37.             if player == selectedPlayer then
  38.                 monitor.setTextColor(colors.green) -- Highlight selected player
  39.             else
  40.                 monitor.setTextColor(colors.white)
  41.             end
  42.             monitor.write(player
  43.  
Advertisement
Add Comment
Please, Sign In to add comment