Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Déclaration de la variable qui stockera l'Advanced Peripherals Player Detector
- local playerDetector
- -- Recherche de l'Advanced Peripherals Player Detector connecté
- for _, peripheralName in ipairs(peripheral.getNames()) do
- if peripheral.getType(peripheralName) == "playerDetector" then
- playerDetector = peripheral.wrap(peripheralName)
- break
- end
- end
- -- Vérification que l'Advanced Peripherals Player Detector a été trouvé
- if playerDetector == nil then
- print("Advanced Peripherals Player Detector non trouvé")
- return
- else
- print("Advanced Peripherals Player Detector trouvé")
- end
- -- Déclaration de la variable qui stockera l'Advanced Peripherals Monitor
- local monitor
- -- Recherche de l'Advanced Peripherals Monitor connecté
- for _, peripheralName in ipairs(peripheral.getNames()) do
- if peripheral.getType(peripheralName) == "monitor" and peripheral.wrap(peripheralName).isColour() then
- monitor = peripheral.wrap(peripheralName)
- break
- end
- end
- -- Vérification que l'Advanced Peripherals Monitor a été trouvé
- if monitor == nil then
- print("Advanced Peripherals Monitor non trouvé")
- return
- else
- print("Advanced Peripherals Monitor trouvé")
- end
- -- Rayon de recherche des joueurs
- local range = 500
- -- Couleurs utilisées dans l'interface graphique
- local backgroundColor = colors.black
- local foregroundColor = colors.white
- local titleColor = colors.blue
- local playerColor = colors.green
- -- Largeur et hauteur de l'écran
- local width, height = monitor.getSize()
- -- Fonction pour afficher l'interface graphique
- local function drawInterface(title, players)
- -- Effacer l'écran avec la couleur de fond
- monitor.setBackgroundColor(backgroundColor)
- monitor.clear()
- -- Afficher le titre de l'interface
- monitor.setBackgroundColor(titleColor)
- monitor.setTextColor(foregroundColor)
- monitor.setCursorPos(1, 1)
- monitor.write(string.rep(" ", width))
- monitor.setCursorPos((width - #title) / 2 + 1, 1)
- monitor.write(title)
- -- Afficher la liste des joueurs
- monitor.setBackgroundColor(backgroundColor)
- monitor.setTextColor(playerColor)
- for i, playerName in ipairs(players) do
- monitor.setCursorPos(2, i + 2)
- monitor.write(playerName)
- end
- -- Afficher le cadre de l'interface
- monitor.setBackgroundColor(foregroundColor)
- monitor.setTextColor(backgroundColor)
- monitor.setCursorPos(1, 1)
- monitor.write(string.rep(" ", width))
- monitor.setCursorPos(1, height)
- monitor.write(string.rep(" ", width))
- for i = 2, height - 1 do
- monitor.setCursorPos(1, i)
- monitor.write(" ")
- monitor.setCursorPos(width, i)
- monitor.write(" ")
- end
- end
- -- Boucle principale du programme
- while true do
- -- Vérification si un joueur est en ligne dans le rayon de recherche
- local playersInRange = playerDetector.getPlayersInRange(range)
- if #playersInRange > 0 then
- -- Si un joueur est en ligne dans le rayon de recherche, émettre un signal de redstone sur le côté arrière
- redstone.setOutput("back", true)
- -- Afficher l'interface graphique avec la liste des joueurs à l'écran
- drawInterface("Joueurs en ligne", playersInRange)
- else
- --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement