Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Wrap peripherals
- local monitor = peripheral.wrap("top")
- local silo = peripheral.wrap("left")
- local playerDetector = peripheral.wrap("right")
- -- Setup the monitor
- monitor.clear()
- monitor.setTextScale(1)
- monitor.setTextColor(colors.white)
- monitor.setBackgroundColor(colors.black)
- -- Monitor dimensions
- local width, height = monitor.getSize()
- -- Table to store player names and their displayed positions
- local playerDisplay = {}
- local selectedPlayer = nil -- Store the selected player's name
- -- Check if the player detector supports coordinate retrieval
- local hasGetPlayerCoords = playerDetector and playerDetector.getPlayerPos ~= nil
- -- Helper function to update the monitor
- local function updateMonitor(players)
- monitor.clear()
- playerDisplay = {} -- Reset playerDisplay table
- if #players > 0 then
- monitor.setCursorPos(1, 1)
- monitor.setTextColor(colors.cyan)
- monitor.write("Players Nearby:")
- for i, player in ipairs(players) do
- local x = 2
- local y = i + 2
- playerDisplay[i] = { name = player, posX = x, posY = y }
- monitor.setCursorPos(x, y)
- if player == selectedPlayer then
- monitor.setTextColor(colors.green) -- Highlight selected player
- else
- monitor.setTextColor(colors.white)
- end
- monitor.write(player
Advertisement
Add Comment
Please, Sign In to add comment