Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- STD_MONITOR_SIDE = "top"
- PLAYER_WHITELIST = {
- mc1030 = true,
- ime990 = true,
- Ajfree = true,
- shirograhm = true,
- RadicalRagu = true
- }
- local moni = peripheral.wrap(STD_MONITOR_SIDE)
- local sensor = peripheral.wrap("right")
- local entities = {}
- local entity_size = 0
- local new_entities = {}
- local new_entity_size = 0
- function welcome(name)
- moni.setTextColor(colors.white)
- print("Welcome "..name)
- monitor_write("Welcome "..name)
- end
- function farewell(name)
- moni.setTextColor(colors.lightBlue)
- print("\tGodspeed "..name)
- monitor_write("\tGodspeed "..name)
- end
- function monitor_reset()
- moni.clear()
- moni.setCursorPos(1, 1)
- moni.setTextColor(colors.white)
- moni.setTextScale(0.5)
- end
- function monitor_write(message)
- moni.write(message)
- local x,y = moni.getCursorPos()
- if y > 8 then
- y = 0
- end
- moni.setCursorPos(1, y + 1)
- end
- monitor_reset()
- while true do
- new_entities = {}
- for _, entity in pairs(sensor.sense()) do
- if PLAYER_WHITELIST[entity.name] ~= nil then
- if entity_size == 0 then
- welcome(entity.name)
- elseif entities ~= nil and entities[entity.name] == nil then
- new_entities[entity.name] = true
- welcome(entity.name)
- end
- new_entities[entity.name] = true
- new_entity_size = new_entity_size + 1
- end
- end
- for name, bool in pairs(entities) do
- if PLAYER_WHITELIST[name] ~= nil then
- if new_entities[name] == nil then
- farewell(name)
- end
- end
- end
- entities = new_entities
- entity_size = new_entity_size
- os.sleep(1.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement