set answer to button returned of (display dialog "Choose a Picture for the Tile Game. The Tiger is the default image. If you choose a folder, a random image from the folder will be selected." buttons {"Tiger", "Choose Folder", "Choose Image"}) set the_user to the second word of (characters (offset of "Users" in path to preferences as string) through (length of (path to preferences as string)) of (path to preferences as string) as string) set the_date to short date string of (current date) set the_time to time of (current date) if answer = "Choose Image" then choose file with prompt "Choose a Picture for the Tile Game" without invisibles set new_image to the result tell application "Finder" try duplicate document file "Tile Game" of folder "Widgets" of folder "Library" of startup disk to folder "Widgets" of folder "Library" of folder the_user of folder "Users" of startup disk end try set name of document file "game.png" of folder "Images" of document file "Tile Game.wdgt" of folder "Widgets" of folder "Library" of folder the_user of folder "Users" of startup disk to the_date & "_" & the_time & "old.png" duplicate new_image to folder "Images" of document file "Tile Game.wdgt" of folder "Widgets" of folder "Library" of folder the_user of folder "Users" of startup disk set name of result to "game.png" end tell end if if answer = "Tiger" then tell application "Finder" try delete document file "Tile Game" of folder "Widgets" of folder "Library" of folder the_user of folder "Users" of startup disk end try end tell end if if answer = "Choose Folder" then choose folder with prompt "Choose a folder of images for the Tile Game" without invisibles set folder_path to the result tell application "Finder" set random_image to some document file in folder folder_path where kind contains "image" try duplicate document file "Tile Game" of folder "Widgets" of folder "Library" of startup disk to folder "Widgets" of folder "Library" of folder the_user of folder "Users" of startup disk end try set name of document file "game.png" of folder "Images" of document file "Tile Game.wdgt" of folder "Widgets" of folder "Library" of folder the_user of folder "Users" of startup disk to the_date & "_" & the_time & "old.png" duplicate random_image to folder "Images" of document file "Tile Game.wdgt" of folder "Widgets" of folder "Library" of folder the_user of folder "Users" of startup disk set name of result to "game.png" end tell end if display dialog "Close and reopen the Tile Game widget for the changes to take effect" buttons {"OK"} default button 1