yeeeeeeeeeeeee

start

Mar 28th, 2025
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. -- startup.lua
  2. local monitor = peripheral.wrap("top")
  3. local locator = peripheral.wrap("right")
  4.  
  5. if not monitor or not locator then
  6. print("Monitor or Player Locator not found!")
  7. return
  8. end
  9.  
  10. monitor.setTextScale(1)
  11. monitor.clear()
  12. monitor.setTextColor(colors.white)
  13. monitor.setBackgroundColor(colors.black)
  14.  
  15. local width, height = monitor.getSize()
  16. local playerDisplay = {}
  17. local selectedPlayer = nil
  18.  
  19. local function getPlayers()
  20. return locator.getPlayersInRange(1000000000000) -- "Infinite" range
  21. end
  22.  
  23. local function updateMonitor(players)
  24. monitor.clear()
  25. playerDisplay = {}
  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)
  39. else
  40. monitor.setTextColor(colors.white)
  41. end
  42. monitor.write(player)
  43. end
  44. else
  45. monitor.setCursorPos(1, math.floor(height / 2))
  46. monitor.setTextColor(colors.red)
  47. monitor.write("No Players Detected")
  48. end
  49. end
  50.  
  51. local players = getPlayers()
  52. updateMonitor(players)
  53.  
  54. while true do
  55. local event, side, x, y = os.pullEvent("monitor_touch")
  56. for _, player in pairs(playerDisplay) do
  57. if x >= player.posX and x <= player.posX + #player.name and y == player.posY then
  58. shell.run("player_info.lua", player.name)
  59. break
  60. end
  61. end
  62. end
Advertisement
Add Comment
Please, Sign In to add comment