Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This is a little screensaver.
- --Made by H4X0RZ (I guess some people on the forums reqeusted this...)
- --To leave it, enter the password and press enter (if no password is entered just press enter)
- --checking if advanced computer
- if term.isColour and term.isColour() then
- else
- error("Please use an advanced computer",0)
- end
- --Varialbes
- local input = ""
- local password = ... or ""
- local oldPull = os.pullEvent
- os.pullEvent = os.pullEventRaw
- local running = true
- local BGc = colors.lightGray --Background color
- local Lc = colors.green --Line color
- local l = {} --lines
- local screenWidth,screenHeight = term.getSize()
- local speed = .4
- --Initialization
- for i = 1, screenWidth do
- if i % 2 == 1 then
- l[i] = screenHeight
- end
- end
- --functions
- local function reading()
- while running do
- local enter = false
- while not enter do
- local sEvent, p1 = os.pullEvent()
- if sEvent == "key" then
- if p1 == keys.enter then
- enter = true
- elseif p1 == keys.backspace then
- input = input:sub(1, #input - 1)
- end
- elseif sEvent == "char" then
- input = input .. p1
- end
- end
- if input == password then
- running = false
- end
- input = ""
- end
- end
- local function update()
- while running do
- for k,v in pairs(l) do
- if math.random(1,2) == 1 then
- if l[k] > 1 then
- l[k] = l[k] - 1
- end
- else
- if l[k] < screenHeight then
- l[k] = l[k] + 1
- end
- end
- end
- sleep(speed)
- end
- end
- local function display()
- while running do
- term.setBackgroundColor(BGc)
- term.clear()
- term.setBackgroundColor(Lc)
- for k,v in pairs(l) do
- paintutils.drawLine(k,screenHeight,k,v,Lc)
- end
- sleep(speed)
- end
- end
- --main loop
- parallel.waitForAny(reading, update, display)
- --The end
- os.pullEvent = oldPull
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.yellow)
- term.write(os.version())
- term.setTextColor(colors.white)
- term.setCursorPos(1,3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement