I know, I am a little bit late (or too early) with this fun project, but if you liked Niftee-Tron’s Hamlet as much as I did, than you should definitely try out the geeky AppleScript Christmas Tree :lol:
The AppleScript Christmas Tree (ca. 265 KB)
The illuminated AppleScript christmas tree in action
The AppleScript Christmas Tree was successfully tested on:
¢ Mac OS X 10.5.1
¢ Mac OS X 10.4
To start the animation, just double-click the AppleScript icon at the end of the tree trunk. There are several illumination types to discover, so lay back and watch the show
The script code can be viewed in the Script Editor and with a little bit of AppleScript-knowledge you can easily create your own illumination routines.
Happy X-Mas (2008)!
P.S.: I really tried my best to preserve the folder view on the disk image to display the christmas tree properly. If it’s broken on your Mac, please note accordingly.
P.S.S.: The AppleScript code is far from being perfect, but it works
Imporant: Opening and saving the below script code in Script Editor won’t result in a usable AppleScript! Therefor please download the complete script here.
-- created: 06.02.2008
property mytitle : "AppleScript Christmas Tree"
property myversion : "0.1b"
on run
my main()
end run
-- I am the main routine controlling the script
on main()
-- ask the user how many times we should illuminate the tree
set rounds to my askforrounds()
-- user hit 'Cancel'-button
if rounds is missing value then
return
end if
-- let's start the illumination
my illuminatetree(rounds)
end main
-- I am asking the user how many times we should illuminate the tree
-- and return this value as an integer.
-- If the user hits the 'Cancel'-button, I return «missing value»
on askforrounds()
set msg to "How many times should we illuminate the christmas tree?"
tell me
activate
display dialog msg default answer "10" buttons {"Cancel", "Enter"} default button 2 with icon note with title mytitle
set dlgresult to result
if button returned of dlgresult is "Cancel" then
return missing value
else
try
-- did the user enter a number?
set rounds to ((text returned of dlgresult) as integer)
-- yes, but he entered a zero, so we ask again!
if rounds is 0 then
my askforrounds()
-- yes, a valid integer!
else
return rounds
end if
-- some people just don't know what a number is...
on error
my askforrounds()
end try
end if
end tell
end askforrounds
-- I am responsible for controlling the tree illumination
on illuminatetree(rounds)
set illufunctions to {"random", "row", "edge"}
tell application "Finder"
set treefolder to (container of (path to me)) as Unicode text
-- resetting the colour of all light folders
set label index of every item in folder treefolder to 0
end tell
repeat rounds times
set illufunction to some item of illufunctions
if illufunction is "random" then
my randomillumination(treefolder)
else if illufunction is "row" then
my rowillumination(treefolder)
else if illufunction is "edge" then
my edgeillumination(treefolder)
end if
end repeat
end illuminatetree
-- I am illuminating random lights on the christmas tree
on randomillumination(treefolder)
set colours to {"1", "2", "3", "4", "5", "6"}
tell application "Finder"
set countlightfolders to 15
set lightfolderpaths to {}
repeat with i from 1 to countlightfolders
repeat
set rnum to random number from 2 to 70
set lightfolderpath to treefolder & rnum & ":"
if lightfolderpath is not in lightfolderpaths then
set lightfolderpaths to lightfolderpaths & lightfolderpath
exit repeat
end if
end repeat
end repeat
repeat with lightfolderpath in lightfolderpaths
set label index of folder lightfolderpath to ((some item of colours) as integer)
delay 0.1
end repeat
delay 1.5
repeat with lightfolderpath in (reverse of lightfolderpaths)
set label index of folder lightfolderpath to 0
delay 0.1
end repeat
delay 1.0
end tell
end randomillumination
-- I am illuminating horizontal rows of light folders
on rowillumination(treefolder)
set colours to {"1", "2", "3", "4", "5", "6"}
set lightrows to {{"1"}, {"2", "3", "4"}, {"5", "6", "7", "8", "9"}, {"10", "11", "12"}, {"13", "14", "15", "16", "17", "18", "19"}, {"20", "21", "22", "23", "24", "25", "26", "27", "28"}, {"29", "30", "31", "32", "33", "34", "35"}, {"36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46"}, {"47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"}, {"60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70"}}
tell application "Finder"
set directions to {"up", "down"}
set direction to some item of directions
if direction is "down" then
repeat with lightrow in lightrows
repeat with lightrownum in lightrow
set lightfolderpath to treefolder & lightrownum & ":"
set label index of folder lightfolderpath to ((some item of colours) as integer)
end repeat
delay 0.4
repeat with lightrownum in lightrow
set lightfolderpath to treefolder & lightrownum & ":"
set label index of folder lightfolderpath to 0
end repeat
delay 0.1
end repeat
else if direction is "up" then
repeat with lightrow in (reverse of lightrows)
repeat with lightrownum in lightrow
set lightfolderpath to treefolder & lightrownum & ":"
set label index of folder lightfolderpath to ((some item of colours) as integer)
end repeat
delay 0.4
repeat with lightrownum in lightrow
set lightfolderpath to treefolder & lightrownum & ":"
set label index of folder lightfolderpath to 0
end repeat
delay 0.1
end repeat
end if
end tell
end rowillumination
-- I am illuminating the light folders on the edge of the tree
on edgeillumination(treefolder)
set colours to {"1", "2", "3", "4", "5", "6"}
set lightrows to {{"1"}, {"2", "3", "4"}, {"5", "6", "7", "8", "9"}, {"10", "11", "12"}, {"13", "14", "15", "16", "17", "18", "19"}, {"20", "21", "22", "23", "24", "25", "26", "27", "28"}, {"29", "30", "31", "32", "33", "34", "35"}, {"36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46"}, {"47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"}, {"60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70"}}
tell application "Finder"
set directions to {"up", "down"}
set direction to some item of directions
if direction is "down" then
repeat with lightrow in lightrows
set lightfolderpathfirst to treefolder & (first item of lightrow) & ":"
set lightfolderpathlast to treefolder & (last item of lightrow) & ":"
set label index of folder lightfolderpathfirst to ((some item of colours) as integer)
set label index of folder lightfolderpathlast to ((some item of colours) as integer)
delay 0.4
set lightfolderpathfirst to treefolder & (first item of lightrow) & ":"
set lightfolderpathlast to treefolder & (last item of lightrow) & ":"
set label index of folder lightfolderpathfirst to 0
set label index of folder lightfolderpathlast to 0
delay 0.1
end repeat
else if direction is "up" then
repeat with lightrow in (reverse of lightrows)
set lightfolderpathfirst to treefolder & (first item of lightrow) & ":"
set lightfolderpathlast to treefolder & (last item of lightrow) & ":"
set label index of folder lightfolderpathfirst to ((some item of colours) as integer)
set label index of folder lightfolderpathlast to ((some item of colours) as integer)
delay 0.4
set lightfolderpathfirst to treefolder & (first item of lightrow) & ":"
set lightfolderpathlast to treefolder & (last item of lightrow) & ":"
set label index of folder lightfolderpathfirst to 0
set label index of folder lightfolderpathlast to 0
delay 0.1
end repeat
end if
end tell
end edgeillumination