So, I was browsing the forums and saw this thread. I noticed that Cranium had noticed (noticeception) that if you removed the term.clear() it became a good screensaver. So I improved it bit by bit, and it turned into the monstrosity that is THIS. It is a screensaver program that I will add to over time that currently has 7 different configurable screensavers, a config, many easter eggs, and so much more! It requires an advanced computer to run. (Unless you change the only colour to white in the config)
Download:
Spoiler
Download it here or by typing:pastebin get YrsrAQtN screensaver
Code:Spoiler
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
Screenshots:
Spoiler
How to use:
Spoiler
On first start up, use:
screensaver <text> [text] [text] etc.
which will first download the files, and then run the 'words' screensaver with your words, printing the text over and over in different colours until you trigger a non-timer os.pullEvent. To change options:
edit shnupProgFiles/screensaver/config.cfg
will edit the config. You can choose 7 different screensavers, disable random colours, change length between prints, etc.Changelog:
Spoiler
BETA 1.1+ Added config file
+ Added 6 new screensaver types - Pixels, Lines, Slideshow, Scrapbook, Indie Letters and Random Letters
+ Added another easter egg
+ Added random case parameter for use with Indie Letters, Random Letters and Words screensavers - -r
+ Now comes with my 'byte' API for decoding bytecode (for separating letters)
+ Now comes with my 'dl' API for downloading the files
+ Now comes with TheOriginalBIT's CConfig
+ Added ability to choose slideshow pictures folder directory in config
+ Added ability to choose wait time between printing stuffs in config
+ Added ability to choose solid colour or random colour in config
+ Added ability to choose screensaver type in config
+ Added -resetConfig parameter for… well, resetting the config
+ Added -changelog parameter for viewing the changelog
^ Changed a lot of the internals (thanks TOBIT!)
^ Changed the incorrect usage screen a fair bit
^ Added TheOriginalBIT to the Credits (now screensaver -credits) and changed the secret code…
* Fixed bug 1
* Fixed bug 2
* Fixed bug 3
Current bugs:
Spoiler
None!If you find any, PM or comment!
Past Versions:
Spoiler
+ = New feature- = Removed feature
* = Fixed bug
^ = Changed feature
Screensaver 1.0
+ First version
DOWNLOAD PB ID: 1RD7HFx0
Planned Future Versions:
Spoiler
+ = New feature- = Removed feature
* = Fixed bug
^ = Changed feature
? = Not sure…
BETA 1.2
+ Adds 4 new screensaver types - Words List [ ], Shapes [ ], Digital Rain [ ] and Snakes [ ]
+ Comes with TheOriginalBIT's loading screen/bar API [ ]
+ Adds loading screen for making files [ ]
+ Adds auto updater
? Installer [ ]
??? I don't know, you tell me! Give me suggestions!
PLANNED RELEASE DATE: ?/4/13
BETA 1.3
+ Adds 1 new screensaver type - Fire [ ]
??? I don't know, you tell me! Give me suggestions!
What I'm Currently up to in Developing the Next Version:
Spoiler
Beta 1.2 DEV. BUILD 1A:> Adds Shapes screensaver [ ]
> Adds (currently unused) TheOriginalBit's loading screen/bar API [ ]
> Adds v1 of the auto updater [ ]
You are allowed to use this in any OS or anything, just give me credit and notify me. Also, do NOT release modified versions unless they are to make it compatible with your OS.
Give me suggestions and bug reports in PMs or comments!