Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- term.clear()
- term.setCursorPos(1,1)
- local version = "CCScreensaver Beta 1.1"
- local changelog = {
- "Added a config (shnupProgFiles/screensaver/config.cfg)",
- "Added 6 screensaver types",
- "Added a new error screen",
- "Edited the credits ("..shell.getRunningProgram().." -credits)",
- "Added -resetConfig, -changelog and -r parameters",
- "Fixed bugs 1, 2 and 3",
- "For more details, see the forum post here:",
- "http://www.computercraft.info/forums2/index.php?/topic/10438-ccscreensaver-beta-10-11-release-date-announced",
- }
- if not fs.exists("shnupProgFiles") then
- if not http then
- print("Sorry, http must be enabled to download the files. Enable in CC's config.")
- return
- end
- print("Since this is your first time using the program, it will download the necessary files. This may take a short while.")
- fs.makeDir("shnupProgFiles")
- end
- if not fs.exists("shnupProgFiles/apis") then
- fs.makeDir("shnupProgFiles/apis")
- end
- if not fs.exists("shnupProgFiles/apis/dl") then
- write("Downloading: shnupProgFiles/apis/dl...")
- local dl = http.request("http://pastebin.com/raw?i=mSP4wJV4")
- while true do
- local event,url,text = os.pullEvent()
- if event == "http_success" then
- f = fs.open("shnupProgFiles/apis/dl","w")
- f.write(text.readAll())
- f.close()
- print(" Done!")
- break
- elseif event == "http_failure" then
- error("Failed to download file: dl API")
- end
- end
- end
- os.loadAPI("shnupProgFiles/apis/dl")
- if not fs.exists("shnupProgFiles/screensaver") then
- fs.makeDir("shnupProgFiles/screensaver")
- end
- if not fs.exists("shnupProgFiles/screensaver/apis") then
- fs.makeDir("shnupProgFiles/screensaver/apis")
- end
- if not fs.exists("shnupProgFiles/screensaver/.secret") then
- fs.makeDir("shnupProgFiles/screensaver/.secret")
- end
- if not fs.exists("shnupProgFiles/screensaver/pictures") then
- fs.makeDir("shnupProgFiles/screensaver/pictures")
- end
- if not fs.exists("shnupProgFiles/screensaver/apis/CConfig") then
- dl.httpDownload("http://pastebin.com/raw?i=iMpzmDWt","shnupProgFiles/screensaver/apis/CConfig")
- end
- os.loadAPI("shnupProgFiles/screensaver/apis/CConfig")
- if not fs.exists("shnupProgFiles/apis/byte") then
- dl.httpDownload("http://pastebin.com/raw?i=ynaCiE75","shnupProgFiles/apis/byte")
- end
- os.loadAPI("shnupProgFiles/apis/byte")
- if not fs.exists("shnupProgFiles/screensaver/.secret/pbjt") then
- dl.httpDownload("http://pastebin.com/raw?i=F1X1VmFJ","shnupProgFiles/screensaver/.secret/pbjt","REDACTED")
- end
- if not fs.exists("shnupProgFiles/screensaver/pictures/flower") then
- dl.httpDownload("http://pastebin.com/raw?i=9CSDMhuB","shnupProgFiles/screensaver/pictures/flower")
- end
- if not fs.exists("shnupProgFiles/screensaver/pictures/hello") then
- dl.httpDownload("http://pastebin.com/raw?i=Hu2iJQs8","shnupProgFiles/screensaver/pictures/hello")
- end
- local config = CConfig.new("shnupProgFiles/screensaver/config.cfg")
- config:load()
- scrnsvrID = config:getNumber("screensaver",0)
- config:addCommentForKey("screensaver","What screensaver to use?")
- config:addRestrictionForKey("screensaver","0 = words, 1 = indie letters, 2 = random letters, 3 = pixels, 4 = lines, 5 = slideshow 6 = scrapbook")
- wait = config:getNumber("waitBetweenPrints",0.005)
- config:addCommentForKey("waitBetweenPrints","How many seconds to wait before printing the next word/pixel/whatever")
- isRandCol = config:getBoolean("randomColour","true")
- config:addCommentForKey("randomColour","Is colour randomly picked each time it prints?")
- col = config:getColour("colourToUse",colours.white)
- config:addCommentForKey("colourToUse","If colour is not random, what colour should it use?")
- picDir = config:getString("slideshowDir","shnupProgFiles/screensaver/pictures")
- config:addCommentForKey("slideshowDir","If the slideshow or scrapbook screensaver is selected, where is the folder with the pictures?")
- config:save()
- term.clear()
- term.setCursorPos(1,1)
- if args[1] then
- local arg1 = string.lower(args[1])
- if arg1 == "-resetconfig" then
- config:reset()
- config:save()
- print("Config reset successfully")
- return
- elseif arg1 == "-credits" then
- term.setCursorPos(1,1)
- print("Coded by: Shnupbups100")
- print("Code originally by: Kingdaro")
- print("FORUMS post wIth idea: Cranium")
- print("LOVElY mOd by: Dan200 and Cloudy")
- print("Under the hood AND CConfig etc.: TheOriginalBIT")
- print("(yes, there's a hidden message in there)")
- return
- elseif arg1 == "-changelog" then
- term.setCursorPos(1,1)
- for i = 1,#changelog do
- print(changelog[i])
- end
- return
- elseif arg1 == "-u" then
- upper = true
- elseif arg1 == "-l" then
- lower = true
- elseif arg1 == "-r" then
- rand = true
- end
- end
- if not args[1] and (scrnsvrID == 0 or scrnsvrID == 1) or args[1] and ((scrnsvrID == 2 and upper == false and lower == false and rand == false) or scrnsvrID == 3 or scrnsvrID == 4 or scrnsvrID == 5) then
- local w,h = term.getSize()
- print(string.rep("-",w))
- term.setCursorPos(w*.5-string.len(version)*.5+1,1)
- print(version)
- print("Usage: ")
- print("While in word or indie letters mode: "..shell.getRunningProgram().." <text> [text] [text] etc.")
- print("While in random letters, lines, slideshow, pixels or scrapbook mode: "..shell.getRunningProgram())
- write("Random Fact Thing: ")
- local facts = {
- "Try using -u, -l or -r instead of the first '<text>' in word/indie letters mode!",
- "Try the program secret/alongtimeago!",
- "Try putting a (regular) monitor and a wither skeleton skull in a crafting bench!",
- "Try erroring this program again like this for more fact things! Collect them all! [/marketingCampain]",
- "These fact things are an easter egg of this program! Shhh! Try to find the one in screensaver -credits!",
- "Pumpkins make good headgear, no annoying angry endermen!",
- "This program has quite a few secrets... this being one of them.",
- "I'm getting bored of typing these",
- "Thnx TheOriginalBIT for stuffs!",
- "To quickly reset the config, use "..shell.getRunningProgram().." -resetconfig",
- "This is the longest fact out of all the facts in the facts table I have written that contains facts because it is very very very long.",
- "There is a hidden folder in shnupProgFiles/screensaver...",
- "The config is found at shnupProgFiles/screensaver/config.cfg",
- "There are 14 random fact things in total.",
- "This fact thing will never show up. Minecraft has a splash screen like this in its .jar.",
- }
- print(facts[math.random(1,#facts-1)])
- print(string.rep("-",w))
- return
- end
- numb1 = 1
- numb2 = 0
- lower = false
- upper = false
- while args[numb1] ~= nil do
- if args[numb1] == "-u" and lower ~= true and rand ~= true then
- upper = true
- elseif args[numb1] == "-l" and upper ~= true and rand ~= true then
- lower = true
- elseif args[numb1] == "-r" and lower ~= true and upper ~= true then
- rand = true
- else
- numb2 = numb2 + string.len(args[numb1]) - 1
- end
- numb1 = numb1 + 1
- end
- numb3 = 1
- used = false
- l = {""}
- local function screensaver()
- local w,h = term.getSize()
- if scrnsvrID ~= 1 then
- local picx = math.random(w)
- local picy = math.random(h)
- term.setCursorPos(math.random(w-numb2),math.random(h))
- else
- term.setCursorPos(math.random(w),math.random(h))
- end
- if isRandCol == true and (scrnsvrID == 0 or scrnsvrID == 1 or scrnsvrID == 2) then
- term.setTextColour(2^math.random(14))
- elseif isRandCol == false and (scrnsvrID == 0 or scrnsvrID == 1 or scrnsvrID == 2) then
- term.setTextColour(col)
- elseif isRandCol == true and (scrnsvrID == 3 or scrnsvrID == 4) then
- term.setBackgroundColour(2^math.random(14))
- elseif isRandCol == false and (scrnsvrID == 3 or scrnsvrID == 4) then
- term.setBackgroundColour(col)
- end
- if scrnsvrID == 0 then
- while args[numb3] ~= nil do
- if args[numb3] ~= "-u" and args[numb3] ~= "-l" and args[numb3] ~= "-r" then
- if upper == true then
- args[numb3] = string.upper(args[numb3])
- elseif lower == true then
- args[numb3] = string.lower(args[numb3])
- elseif rand == true then
- local randChance = math.random(2)
- if randChance == 1 then
- args[numb3] = string.upper(args[numb3])
- else
- args[numb3] = string.lower(args[numb3])
- end
- end
- numb4 = numb3 + 1
- term.write(args[numb3])
- end
- if args[numb4] and args[numb4] ~= "-u" and args[numb4] ~= "-l" then
- term.write(" ")
- end
- numb3 = numb3 + 1
- end
- numb3 = 1
- elseif scrnsvrID == 1 then
- while args[numb3] ~= nil do
- if args[numb3] == "-u" then
- numb3 = numb3 + 1
- if upper == true then
- args[numb3] = string.upper(args[numb3])
- end
- elseif args[numb3] == "-l" then
- numb3 = numb3 + 1
- if lower == true then
- args[numb3] = string.lower(args[numb3])
- end
- elseif args[numb3] == "-r" then
- numb3 = numb3 + 1
- if rand == true then
- local randChance = math.random(100)
- if randChance < 50 then
- args[numb3] = string.upper(args[numb3])
- elseif randChance >= 50 then
- args[numb3] = string.lower(args[numb3])
- end
- end
- else
- for i = 1,string.len(args[numb3]) do
- table.insert(l,#l+1,string.char(string.byte(args[numb3],i)))
- end
- numb3 = numb3 + 1
- end
- end
- local letter = math.random(#l)
- local lett = l[letter]
- if upper == true then
- local lett = string.upper(lett)
- elseif lower == true then
- local lett = string.lower(lett)
- elseif rand == true then
- local randChance = math.random(100)
- if randChance < 50 then
- local lett = string.upper(lett)
- elseif randChance >= 50 then
- local lett = string.lower(lett)
- end
- end
- write(lett)
- elseif scrnsvrID == 2 then
- local letter = byte.decode(math.random(32,126))
- if letter ~= false then
- if upper == true then
- letter = string.upper(letter)
- elseif lower == true then
- letter = string.lower(letter)
- elseif rand == true then
- local randChance = math.random(100)
- if randChance < 50 then
- letter = string.upper(letter)
- elseif randChance >= 50 then
- letter = string.lower(letter)
- end
- end
- write(letter)
- end
- elseif scrnsvrID == 3 then
- term.write(" ")
- elseif scrnsvrID == 4 then
- for i = 1,h do
- local x,y = term.getCursorPos()
- write(" ")
- local y = y + 1
- term.setCursorPos(x,y)
- end
- elseif scrnsvrID == 5 then
- if fs.exists(picDir) and fs.isDir(picDir) then
- local pics = fs.list(picDir)
- local pic = math.random(#pics)
- local image = paintutils.loadImage(picDir.."/"..pics[pic])
- paintutils.drawImage(image,1,1)
- term.setBackgroundColour(colours.black)
- else
- error("Folder not found: "..picdir)
- end
- elseif scrnsvrID == 6 then
- if fs.exists(picDir) and fs.isDir(picDir) then
- local pics = fs.list(picDir)
- local pic = math.random(#pics)
- local image = paintutils.loadImage(picDir.."/"..pics[pic])
- paintutils.drawImage(image,math.random(w),math.random(h))
- term.setBackgroundColour(colours.black)
- else
- error("Folder not found: "..picDir)
- end
- end
- end
- while true do
- screensaver()
- os.startTimer(wait)
- event,p1,p2,p3 = os.pullEvent()
- if scrnsvrID == 5 then
- term.clear()
- end
- if event ~= "timer" then
- term.setTextColour(colours.white)
- term.setBackgroundColour(colours.black)
- term.clear()
- term.setCursorPos(1,1)
- os.unloadAPI("shnupProgFiles/apis/dl")
- os.unloadAPI("shnupProgFiles/apis/byte")
- os.unloadAPI("shnupProgFiles/screensaver/apis/CConfig")
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment