Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --different possible groupings and their
- --corresponding greetings
- local groupings = {
- {"kaibochan"},
- {"kaibochan", "sethrl"},
- {"sethrl"},
- {"N0LIF3RRE3"},
- {"kaibochan", "N0LIF3RRE3"},
- {"N0LIF3RRE3", "sethrl"},
- {"kaibochan", "N0LIF3RRE3", "sethrl"},
- }
- local greetings = {
- "Welcome back, Kai",
- "Welcome, disciples",
- "Hey cutie ;-)",
- "ICEJJPICK!?",
- "ADHD squad B-)",
- "TWO CUTIES!?\nAT MY BASE!?",
- "What's up CS squad",
- }
- local settings = {
- {
- ["scale"] = 1,
- ["textColor"] = colors.lime,
- ["bgColor"] = colors.black,
- },
- {
- ["scale"] = 1,
- ["textColor"] = colors.yellow,
- ["bgColor"] = colors.black,
- },
- {
- ["scale"] = 2,
- ["textColor"] = colors.pink,
- ["bgColor"] = colors.black,
- },
- {
- ["scale"] = 2,
- ["textColor"] = colors.black,
- ["bgColor"] = colors.white,
- },
- {
- ["scale"] = 2,
- ["textColor"] = colors.red,
- ["bgColor"] = colors.black,
- },
- {
- ["scale"] = 1,
- ["textColor"] = colors.red,
- ["bgColor"] = colors.white,
- },
- {
- ["scale"] = 1,
- ["textColor"] = colors.lightBlue,
- ["bgColor"] = colors.black,
- },
- }
- --default text displayed when no players
- local defaultText = "Biopunk"
- local defaultSettings = {
- ["scale"] = 2,
- ["textColor"] = colors.lime,
- ["bgColor"] = colors.black,
- }
- function main()
- --find peripherals
- monitor = peripheral.find("monitor")
- playerDetector = peripheral.find("playerDetector")
- --sort each grouping for easy comparison
- for i, group in ipairs(groupings) do
- table.sort(group)
- end
- while true do
- --only activate once every 1/8 of a second
- sleep(1/8)
- monitor.clear()
- monitor.setCursorPos(1, 1)
- --get a sorted list of nearby players
- local players = playerDetector.getPlayersInCubic(2, 2, 2)
- table.sort(players)
- --if no players nearby, display default
- --text
- if #players == 0 then
- monitor.setTextScale(defaultSettings.scale)
- monitor.setTextColor(defaultSettings.textColor)
- monitor.setBackgroundColor(defaultSettings.bgColor)
- monitor.write(defaultText)
- else
- local foundGroup
- --iterate through all different groups
- for i, group in ipairs(groupings) do
- foundGroup = true
- --iterate through names within the
- --current group, checking for a
- --match, then printing the
- --corresponding greeting
- if #players == #group then
- for j, name in ipairs(group) do
- if players[j] ~= name then
- foundGroup = false
- end
- end
- else
- foundGroup = false
- end
- if foundGroup then
- monitor.setTextScale(settings[i].scale)
- monitor.setTextColor(settings[i].textColor)
- monitor.setBackgroundColor(settings[i].bgColor)
- monitor.write(greetings[i])
- break
- end
- end
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement