Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- AUTOMATIC INSTALLATION
- -- 1. Execute: 'pastebin run dRKxpGwC install'
- -- 2. Wait for reboot
- -- 3. Stop current programm (CTRL+T or button near shutdown)
- -- 4. Edit 'lines' file
- -- 5. Reboot
- -- MANUAL INSTALLATION
- -- 1. Create file 'lines' with texts
- -- 2. Create 'startup.lua' with code: 'shell.execute("runline")'
- -- 3. Download the script: 'pastebin get dRKxpGwC runline.lua'
- -- 4. Reboot your Computer
- -- LINES file
- -- Each new line is a new running line
- -- Special directives starts with #
- -- Directives key and value divides by :
- -- Here is directives:
- -- #fg:[color_name] -- #fg:red
- -- #bg:[color_name] -- #bg:black
- -- #dl:[run_delay] -- #dl:0.1
- local args = { ... }
- local file, delay = args[1], args[2]
- if file == "install" then
- -- Downloading main script
- local req = http.get("https://pastebin.com/raw/dRKxpGwC")
- local f_runline = io.open("runline.lua", "w+")
- f_runline:write(req:readAll())
- f_runline:close()
- req:close()
- -- Configuring startup
- local f_startup = io.open("startup.lua", "w+")
- f_startup:write("shell.execute('runline', 'lines', '0.2')")
- f_startup:close()
- -- Creating lines example
- local f_lines = io.open("lines", "w+")
- f_lines:write(":: RUNNING LINE ::\n")
- f_lines:write(":: EXAMPLE TEXT ::")
- f_lines:close()
- -- Rebooting
- os.reboot()
- end
- local function write(text, fg, bg)
- local mons = { peripheral.find("monitor") }
- for _, mon in pairs(mons) do
- mon.setTextColor(fg)
- mon.setBackgroundColor(bg)
- mon.clear()
- mon.setTextScale(5)
- mon.setCursorPos(1, 1)
- mon.write(text)
- end
- end
- local function runline(line, delay, fg, bg)
- local pad = " "
- local line = pad .. line .. pad
- for i = 1, #line, 1 do
- write(string.sub(line, i, i+16), fg, bg)
- os.sleep(delay)
- end
- end
- local function runlist(list, delay)
- local fg = colors.white
- local bg = colors.black
- local dl = delay
- while true do
- for i = 1, #list do
- if string.sub(list[i], 1, 1) == "#" then
- -- Parsing directive
- local directive = string.sub(list[i], 2, -1)
- dparts = {}
- for dpart in string.gmatch(directive, "([^:]+)") do
- dparts[#dparts+1] = dpart
- end
- if dparts[1] == "fg" then
- fg = colors[dparts[2]]
- end
- if dparts[1] == "bg" then
- bg = colors[dparts[2]]
- end
- if dparts[1] == "dl" then
- dl = tonumber(dparts[2])
- end
- else
- -- Running line
- runline(list[i], dl, fg, bg)
- end
- end
- end
- end
- while true do
- local lines = {
- ":: RUNNING LINE ::",
- "Pass the filename arg, or create lines file"
- }
- if file == nil then
- local h = fs.open("lines", "r")
- if h ~= nil then
- h.close()
- file = "lines"
- end
- end
- if file ~= nil then
- lines = {}
- for line in io.lines(file) do
- lines[#lines+1] = line
- end
- end
- if delay == nil then
- delay = 0.2
- end
- runlist(lines, tonumber(delay))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement