Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CCWelcome
- os.loadAPI("ocs/apis/sensor")
- local worldsensor = sensor.wrap("left")
- local proximitysensor = sensor.wrap("right")
- local monitor = peripheral.wrap("top")
- function printf(object)
- print(textutils.serialize(object))
- end
- local replaceNames = {
- ["Qwertiiiiiii"] = "Nina",
- ["zamunda63"] = "Dennis",
- ["leLucy"] = "lucy",
- ["Schokimann"] = "Paul",
- }
- function clearLine()
- local w,_ = monitor.getSize()
- local x,y = monitor.getCursorPos()
- local toFill = ""
- for i=2,w-2 do
- toFill = toFill.." "
- end
- monitor.setCursorPos(2,y)
- monitor.write(toFill)
- monitor.setCursorPos(x,y)
- end
- function printPlayerLine(targetName, target)
- local type = target.Name
- if type == "Player" then
- local name = targetName
- local nameToGreet
- if replaceNames[name] ~= nil then
- nameToGreet = replaceNames[name]
- else
- nameToGreet = name
- end
- if name == "Qwertiiiiiii" then
- monitor.write("Welcome home, ")
- monitor.setTextColor(colors.yellow)
- monitor.write(nameToGreet)
- else
- monitor.write("Welcome, ")
- monitor.setTextColor(colors.yellow)
- monitor.write(nameToGreet)
- end
- monitor.setTextColor(colors.white)
- end
- end
- local lastLine = 0
- monitor.clear()
- local w,h = monitor.getSize()
- monitor.setBackgroundColor(colors.lightBlue)
- for i=1,h+1 do
- if i == 1 or i == h+1 then
- monitor.clearLine()
- else
- monitor.setCursorPos(1,i)
- monitor.write(" ")
- monitor.setCursorPos(w,i)
- monitor.write(" ")
- end
- end
- monitor.setBackgroundColor(colors.black)
- function preparePrintM(line)
- monitor.setCursorPos(3,line)
- clearLine()
- end
- function getTime()
- local time = os.time()
- return textutils.formatTime(time, false)
- end
- function printEnv()
- local line = h-3
- local environment = worldsensor.getTargetDetails("CURRENT")
- preparePrintM(line)
- if environment.Daytime then
- monitor.setTextColor(colors.yellow)
- monitor.write("Today ")
- else
- monitor.setTextColor(colors.gray)
- monitor.write("Tonight ")
- end
- monitor.setTextColor(colors.white)
- if environment.Thundering then
- monitor.write("is a stormy ")
- elseif environment.Raining then
- monitor.write("is a rainy ")
- else
- if time == "day" then
- monitor.write("is a sunny ")
- else
- monitor.write("is a clear ")
- end
- end
- if environment.Daytime then
- monitor.write("day")
- else
- monitor.write("night")
- end
- line = line+1
- preparePrintM(line)
- monitor.write("It's "..getTime())
- end
- while true do
- local proxtargets = proximitysensor.getTargets()
- local line = 3
- for k,v in pairs(proxtargets) do
- preparePrintM(line)
- printPlayerLine(k,v)
- line = line + 1
- end
- while line < lastLine do
- monitor.setCursorPos(1,line)
- clearLine()
- line = line + 1
- end
- lastLine = line
- printEnv()
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement