1

我正在为 Minecraft 创建一个仅适用于 Mac 的 Mod 安装程序。它使用多个应用程序分别执行一项任务(每个都是一个 applescript 应用程序)。但是今天我开始制作一个可以做所有事情的应用程序。当我完成脚本并尝试编译时,它给了我语法错误:预期的行尾等,但找到了脚本的结尾。我想我一切都好,但我不知道是什么原因造成的。这是代码:

say "You are running iCraft version one point one for minecraft version 1.2.5"
display dialog "Which tool do you want to use?" buttons {"Mod Installer", "Backup", "Restore"} default button 3
set the button_pressed to the button returned of the result 
    if the button_pressed is "Mod Installer" then
        do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/installer.sh"
            display dialog "Insert all mod files into the Mods folder."
            display dialog "Have you inserted all Mod files into the Mods folder?" buttons {"Yes", "No"} default button 2
                    if the button_pressed is "Yes" then
                        do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/installer2.sh"
                                display dialog "Finished"
                        else
                            display dialog "Insert mod files into the Mods folder and restart iCraft.app."
                        end if
if the button_pressed is "Backup" then
    display dialog "Are you sure you want to backup your Minecraft.jar in it's current state?" buttons {"Yes", "No"} default button 2                       
            if the button_pressed is "Yes" then
                    do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/backup.sh"
                            display dialog "Finished, find it in your Backups directory in the iCraft folder"
            else
                display dialog "Backup aborted"             
            end if
else
    display dialog "Are you sure you want to restore your Minecraft.jar with your backup?" buttons {"Yes", "No"} default button 2
            if the button_pressed is "Yes" then
                do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/restore.sh"
                        display dialog "Restore finished"
            else
                display dialog "Restore aborted"            
end if
end
4

2 回答 2

2

最后一个end if实际上是结束if缩进的,使外部if没有end if. 反之亦然,但是您想查看它。

换句话说,end if在最后一行之前添加另一个。

于 2012-06-10T16:22:24.630 回答
1

这将起作用:

say "You are running iCraft version one point one for minecraft version 1.2.5"
display dialog "Which tool do you want to use?" buttons {"Mod Installer", "Backup", "Restore"} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "Mod Installer" then
    do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/installer.sh"
    display dialog "Insert all mod files into the Mods folder."
    display dialog "Have you inserted all Mod files into the Mods folder?" buttons {"Yes", "No"} default button 2
    if the button_pressed is "Yes" then
        do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/installer2.sh"
        display dialog "Finished"
    else
        display dialog "Insert mod files into the Mods folder and restart iCraft.app."
    end if
    if the button_pressed is "Backup" then
        display dialog "Are you sure you want to backup your Minecraft.jar in it's current state?" buttons {"Yes", "No"} default button 2
        if the button_pressed is "Yes" then
            do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/backup.sh"
            display dialog "Finished, find it in your Backups directory in the iCraft folder"
        else
            display dialog "Backup aborted"
        end if
    else
        display dialog "Are you sure you want to restore your Minecraft.jar with your backup?" buttons {"Yes", "No"} default button 2
        if the button_pressed is "Yes" then
            do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/restore.sh"
            display dialog "Restore finished"
        else
            display dialog "Restore aborted"
        end if
    end if
end if
于 2014-02-20T16:56:16.317 回答