Mounting a .dmg from "choose list" with Toast titanium

Hey and hello,
I have a question. I want to have a list from which I can choose a Game. By selecting the game Toast Titanium should automatically mound the needed image file of the game. I want to do this because I’m travelling a lot and don’t want to take all the discs and so on.

What I got so far is:
I get the list, I can choose from the list, but than Toast TTitanium tells me the “gamedisc” variable is not set. Does anybody has a solution for me, becaus i set the variable within the if-loop (or do I not?). Is there maybe a more elegant way to solve this problem? Also If i quit the game is it possible to eject the disc again? How can that be triggered?

THX in advance and a happy new year for everybody :wink:
goeste


set Games to {"Age Of Empires III", "Age Of Empires III TAD", "Age Of Empires III TWC"}
set theGame to (choose from list Games with title "Wähle ein Spiel" with prompt "Spiel: ")
set image1 to "/Users/goeste/Stuff/AOE III /Age of Empires III .dmg"
set image2 to "/Users/goeste/Stuff/AOE III /AOE III - The Asian Dynasties.dmg"
set image3 to "/Users/goeste/Stuff/AOE III /Age of Empires III The WarChiefs.dmg"

if theGame is item 1 of Games then
	set gamedisc to image1
else if theGame is item 2 of Games then
	set gamedisc to image2
else if theGame is item 3 of Games then
	set gamedisc to image3
end if

tell application "Toast Titanium"
	mount image gamedisc
	quit "Toast Titanium"
end tell

Model: MBP 2,4GHz, 4GB Ram, 250GB HDD, mid2010
Browser: Safari 533.19.4
Operating System: Mac OS X (10.6)

Hi,

this is a common error. choose from list returns always a list.
This addition checks if the user presses “Cancel” and flattens the list


.
set theGame to (choose from list Games with title "Wähle ein Spiel" with prompt "Spiel: ")
if theGame is false then return
set theGame to item 1 of theGame
.

Hi StefanK,

AWESOME :wink: Thank you very much, it works :slight_smile: now the game needs to be started but I guess I can figure that out by myself :slight_smile:

BTW, here is what it looks as a whole (just the mounting):


set Games to {"Age Of Empires III", "Age Of Empires III TAD", "Age Of Empires III TWC"}
set theGame to (choose from list Games with title "Wähle ein Spiel" with prompt "Spiel: ")
set image1 to "/Users/goeste/Stuff/AOE III /Age of Empires III .dmg"
set image2 to "/Users/goeste/Stuff/AOE III /AOE III - The Asian Dynasties.dmg"
set image3 to "/Users/goeste/Stuff/AOE III /Age of Empires III The WarChiefs.dmg"

if theGame is false then return
set theGame to item 1 of theGame

if theGame is item 1 of Games then
   set gamedisc to image1
else if theGame is item 2 of Games then
   set gamedisc to image2
else if theGame is item 3 of Games then
   set gamedisc to image3
end if

tell application "Toast Titanium"
   mount image gamedisc
   quit "Toast Titanium"
end tell

This is a version without if - else if - end if


set AOE_III_Folder to ((path to home folder as text) & "Stuff:AOE III:")
set Games to {"1 Age Of Empires III", "2 Age Of Empires III TAD", "3 Age Of Empires III TWC"}
set Images to {"Age of Empires III .dmg", "AOE III - The Asian Dynasties.dmg", "Age of Empires III The WarChiefs.dmg"}
set theGame to (choose from list Games with title "Wähle ein Spiel" with prompt "Spiel: ")
if theGame is false then return
set theGame to text 1 of (item 1 of theGame) as integer
set gamedisc to AOE_III_Folder & item theGame of Images

tell application "Toast Titanium"
	mount image (gamedisc as alias)
	quit "Toast Titanium"
end tell


Okay, here is another version that gets the right application automatically and has the images embedded. Now I just want to embed the ToastImageMounter into the app-bundle. I got it so far, but I cannt get it to run. Can any one help me with it? my approach would be something like:


do shell script imagemounter gamedisc

is it the right approach/direction?

BTW, here is the whole script:


set location to POSIX path of (path to me as string)
set imagemounter to location & "/ToastImageMounter" as string
set Games to {"Age Of Empires III", "Age Of Empires III TWC", "Age Of Empires III TAD"}
set theGame to (choose from list Games with title "Wähle ein Spiel" with prompt "Spiel: ")

-- images
set image1 to location & "/Contents/Resources/discimages/AOE III.dmg"
set image2 to location & "/Contents/Resources/discimages/AOE III TWC.dmg"
set image3 to location & "/Contents/Resources/discimages/AOE III TAD.dmg"

-- find game apps
tell application "Finder"
	set aoe3 to POSIX path of (application file id "Age3" as string)
	set aoe3twc to POSIX path of (application file id "Ag3Y" as string)
	set aoe3tad to POSIX path of (application file id "Ag3X" as string)
end tell

-- get the chosen item
if theGame is false then return
set theGame to item 1 of theGame

-- setting the right gamedisc image
if theGame is item 1 of Games then
	set gamedisc to image1
else if theGame is item 2 of Games then
	set gamedisc to image2
else if theGame is item 3 of Games then
	set gamedisc to image3
end if

-- mount the selected image
-- imagemounter
-- mount image gamedisc
-- end tell

-- open the selected game
if gamedisc is image1 then
	tell application aoe3 to activate
else if gamedisc is image2 then
	tell application aoe3twc to activate
else if gamedisc is image3 then
	tell application aoe3tad to activate
end if

-- unmount image
-- needs to be fixed