Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w, h = term.getSize()
- local function cprint(str, nocenterheight)
- local _w, _h = term.getCursorPos()
- local xpos = math.floor(w/2 - str:len()/2)
- local ypos = (not nocenterheight and math.floor(h/2)) or _h
- term.setCursorPos(xpos, ypos)
- term.write(str)
- end
- local animations = {
- function (str) -- flash
- for i = 1, 5 do
- cprint(str)
- sleep(0.5)
- term.clear()
- sleep(0.5)
- end
- end,
- function(str) -- marquee
- for i = w+1, -str:len() - 1, -1 do
- term.clear()
- term.setCursorPos(i, math.floor(h/2))
- term.write(str)
- sleep(0.1)
- end
- end,
- function(str) -- random fill
- local screen = {}
- local clear = false
- local pos = 0
- local function setscreen(x, y, char)
- if clear then char = " " end
- --if y == math.floor(h/2) and x > math.floor(w/2 - str:len()/2) and x < math.floor(w/2 + str:len()/2) then
- --end
- if not screen[x] then screen[x] = {} end
- screen[x][y] = char
- end
- while true do
- for i = 1, 50 do
- setscreen(math.random(1, w), math.random(1, h), string.char(math.random(32, 126)))
- for n = 1, str:len() do
- if n <= pos then
- setscreen(math.floor(w/2 - str:len()/2) + n - 1, math.floor(h/2), str:sub(n, n))
- end
- end
- for x, ytbl in pairs(screen) do
- for y, char in pairs(ytbl) do
- term.setCursorPos(x, y)
- term.write(char)
- end
- end
- --term.setCursorPos(math.floor(w/2 - str:len()/2), math.floor(h/2))
- --term.write(str:sub(1, pos))
- end
- pos = pos + 1
- if pos > str:len() then
- term.clear()
- term.setCursorPos(math.floor(w/2 - str:len()/2), math.floor(h/2))
- term.write(str:sub(1, pos))
- sleep(3)
- break
- end
- sleep(0)
- end
- end,
- }
- local messages = {
- "Welcome to the Server!",
- "Play Nice!",
- }
- local lasta = -1
- local lastm = -1
- while true do
- local message = math.random(#messages)
- while message == lastm do message = math.random(#messages) end
- lastm = message
- local animation = math.random(#animations)
- while animation == lasta do animation = math.random(#animations) end
- lasta = animation
- term.setTextColor(2^math.random(0, 15))
- animations[animation](messages[message])
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement