--MurgaPlayer Main Script July 17 2007

set |quote| to "\""

-- path to the folder that contains the player

set apppath to GetParentPath(path to me)

set uniPath to POSIX path of apppath

set storePath to uniPath & "murgaPlayer.app/Data/Scripts/bundleroot.lua" as string


set lineOne to quote & "bundleroot='" & uniPath & "murgaPlayer.app/'" & return as string

set lineTwo to "dofile(bundleroot..'" & "Data/Scripts/start.lua'" & ")" & quote as string


set echoOut to lineOne & lineTwo

set echoDir to "echo " & echoOut & " > " & storePath as string

do shell script (echoDir)


-- path to the murgalua file within the bundle

set Executemurgalua to POSIX path of (path to me as string) & "Contents/MacOS/murgaLua"


-- name of the script to launch, within the current folder

set startScript to POSIX path of (path to me as string) & "Data/Scripts/bundleroot.lua"


-- constructing the shell command

set cdtoapppath to "cd '" & the POSIX path of apppath & "'; " & Executemurgalua & " " & startScript

do shell script (cdtoapppath)


on GetParentPath(theFile)

tell application "Finder" to return container of theFile as text

end GetParentPath