Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local arg = ...
- local function getPeripheral()
- print("Searching sensor...")
- local sides = {"top", "bottom", "right", "left", "back", "front"}
- local sensor = peripheral.wrap("top")
- local i = 1
- while sensor == nil do
- sensor = peripheral.wrap(tostring(sides[i]))
- i = i + 1
- if i % 7 == 0 then
- i = 1
- end
- sleep(0)
- end
- print("Sensor found !")
- return sensor
- end
- local function displayAllAttributes(tab)
- for k,v in ipairs(tab) do
- print(k)
- print(type(v))
- if type(v) == "table" then
- displayAllAttributes(v)
- else
- print(v)
- end
- end
- end
- local function getNames(sensor)
- players = {}
- i = 1
- for _,v in ipairs(sensor.getPlayers()) do
- players[i] = v.name
- i = i + 1
- end
- return players
- end
- local function displayPlayersInRange(sensor, times)
- local i = 0
- while i ~= times do
- term.clear()
- for _,players in ipairs(getNames(sensor)) do
- print(players)
- end
- i = i + 1
- sleep(1)
- end
- end
- local function main()
- local sensor = getPeripheral()
- if arg == nil then
- displayPlayersInRange(sensor, -1)
- else
- displayPlayersInRange(sensor, arg)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement