Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Settings
- function prog()
- local delay = 5
- local strings2 = {}
- local strings = {}
- for i, v in pairs(fs.list("ftp")) do
- local f = fs.open(fs.combine("ftp",v),"r")
- table.insert(strings2,f.readAll())
- f.close()
- end
- if strings ~= strings2 then
- strings = strings2
- end
- assert(#strings[1], "Please input a string!")
- local mon = nil
- for _, side in pairs(rs.getSides()) do
- if peripheral.getType(side) == "monitor" then
- mon = peripheral.wrap(side)
- end
- end
- assert(mon, "No monitor found")
- mon.setTextScale(5)
- local w, h = mon.getSize()
- local function strLen(str)
- str = str:gsub("&[0-9a-fA-F]", ""):gsub("&&", "&")
- return #str
- end
- local function centerWrite(str)
- mon.clear()
- mon.setTextColor(colors.white)
- local lines = {}
- local words = {}
- local l = 0
- for word in str:gmatch("[^ ]+") do
- if l == 0 or #lines[l] + strLen(word) > w then
- l = l + 1
- lines[l] = word
- else
- lines[l] = lines[l] .. " " .. word
- end
- end
- local y = math.floor((h - #lines) / 2)
- if y < 0 then y = 0 end
- for l = 1, #lines do
- local line = lines[l]
- local x = math.floor((w - strLen(line)) / 2) + 1
- mon.setCursorPos(x, l + y)
- local escape = false
- for c = 1, #line do
- local char = line:sub(c, c)
- if escape then
- char = char:lower()
- if char == "0" then mon.setTextColor(colors.black)
- elseif char == "1" then mon.setTextColor(colors.blue)
- elseif char == "2" then mon.setTextColor(colors.green)
- elseif char == "3" then mon.setTextColor(colors.brown)
- elseif char == "4" then mon.setTextColor(colors.red)
- elseif char == "5" then mon.setTextColor(colors.purple)
- elseif char == "6" then mon.setTextColor(colors.orange)
- elseif char == "7" then mon.setTextColor(colors.lightGray)
- elseif char == "8" then mon.setTextColor(colors.gray)
- elseif char == "9" then mon.setTextColor(colors.lightBlue)
- elseif char == "a" then mon.setTextColor(colors.lime)
- elseif char == "b" then mon.setTextColor(colors.cyan)
- elseif char == "c" then mon.setTextColor(colors.pink)
- elseif char == "d" then mon.setTextColor(colors.magenta)
- elseif char == "e" then mon.setTextColor(colors.yellow)
- elseif char == "f" then mon.setTextColor(colors.white)
- elseif char == "&" then mon.write("&")
- end
- escape = false
- elseif char == "&" then
- escape = true
- else
- mon.write(char)
- end
- end
- end
- end
- local i = 1
- while true do
- centerWrite(strings[i])
- i = i % #strings + 1
- strings = {}
- for i, v in pairs(fs.list("ftp")) do
- local f = fs.open(fs.combine("ftp",v),"r")
- table.insert(strings2,f.readAll())
- f.close()
- end
- if strings ~= strings2 then
- strings = strings2
- if i > #strings then
- i = 1
- end
- end
- sleep(delay)
- end
- end
- parallel.waitForAny((function() shell.run("ftpserv") end),prog)
Advertisement
Add Comment
Please, Sign In to add comment