Jump to content




Screensaver v1.1!


  • You cannot reply to this topic
4 replies to this topic

#1 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 17 December 2012 - 06:19 AM

Thanks to TheOriginalBIT for helping me fix some of my bugs. This is just a simple screensaver that draws random pixels, then clears the screen. You can go ahead and put this in your operating system without my permission.

Code: pastebin get XXW0r5zt

Changelog:
Spoiler


#2 AndreWalia

  • Members
  • 294 posts
  • LocationSt.Louis, MO

Posted 17 December 2012 - 10:57 AM

I like it. But with most screen savers for IRL computers it also stops the screen saver if you click the mouse. So I added that by changing one line.
local maxX, maxY = term.getSize()
local count = 1
local d = {}
local resetTimer = os.startTimer(5)
local addTimer = os.startTimer(0.1)
local function clear()
  term.setBackgroundColor(colors.black)
  term.clear()
  term.setCursorPos(1,1)
end
while true do
  event = { os.pullEventRaw() }
  if event[1] == "key" or event[1] == "mouse_click" then
    clear()
    return
  elseif event[1] == "timer" then
    if event[2] == addTimer then
	  t = {
	  ["x"] = math.random(1,maxX),
	  ["y"] = math.random(1,maxY),
	  ["color"] = 2^math.random(0,15)
	  }
	  table.insert(d, t)
	  addTimer = os.startTimer(0.1)
    elseif event[2] == resetTimer then
	  d = {}
	  resetTimer = os.startTimer(5)
    end
  end
  clear()
  for _, v in pairs( d ) do
    term.setCursorPos( v["x"], v["y"] )
    term.setBackgroundColor(v["color"])
    write(" ")
  end
end
Its Pastebin id is fEAC4Ave

#3 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 17 December 2012 - 11:13 AM

View Postwalia6, on 17 December 2012 - 10:57 AM, said:

I like it. But with most screen savers for IRL computers it also stops the screen saver if you click the mouse. So I added that by changing one line.
local maxX, maxY = term.getSize()
local count = 1
local d = {}
local resetTimer = os.startTimer(5)
local addTimer = os.startTimer(0.1)
local function clear()
  term.setBackgroundColor(colors.black)
  term.clear()
  term.setCursorPos(1,1)
end
while true do
  event = { os.pullEventRaw() }
  if event[1] == "key" or event[1] == "mouse_click" then
    clear()
    return
  elseif event[1] == "timer" then
    if event[2] == addTimer then
	  t = {
	  ["x"] = math.random(1,maxX),
	  ["y"] = math.random(1,maxY),
	  ["color"] = 2^math.random(0,15)
	  }
	  table.insert(d, t)
	  addTimer = os.startTimer(0.1)
    elseif event[2] == resetTimer then
	  d = {}
	  resetTimer = os.startTimer(5)
    end
  end
  clear()
  for _, v in pairs( d ) do
    term.setCursorPos( v["x"], v["y"] )
    term.setBackgroundColor(v["color"])
    write(" ")
  end
end
Its Pastebin id is fEAC4Ave

Ah, yes, completely forgot about the mouse. I'll add that later.

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 17 December 2012 - 03:21 PM

View PostDlcruz129, on 17 December 2012 - 06:19 AM, said:

Thanks to TheOriginalBIT for helping me fix some of my bugs.

Your welcome :) I had similar issues with mine when I did it. You inspired me to release mine :)

View Postwalia6, on 17 December 2012 - 10:57 AM, said:

I like it. But with most screen savers for IRL computers it also stops the screen saver if you click the mouse. So I added that by changing one line.

Would you not have it on any mouse event? o.O Thats what I did

#5 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 18 December 2012 - 07:47 AM

Version 1.1 is out!

New in this version: Clicking will now exit the screensaver.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users