为什么我的 Applescript IF Loop 和 "Equals To" 运算符无法正常工作?

Why is my Applescript IF Loop and "Equals To" operator not working properly?

我有一个 applescript 进度条模拟器,我有用户 select 列表中的一个菜单项:

set gameMenuOption to choose from list simMenu with prompt "
Slot: " & item slot of gameslots & "

Mulla: $" & gameMulla & "
Assets: " & gameAssets & "
Speed: " & gameLoadSpeed & "Assets Per Second"

提示基本上是用户的资产,金钱等。所以当他们从菜单中select一些东西时,他们也可以看看他们的统计数据。因此,当他们 select 某些东西时,它会处理输入:

if gameMenuOption = "Shop" then
    set gameShopOption to choose from list simShop with prompt "Shop: "
else if gameMenuOption is equal to "Load Progress Bar" then
    --not finished yet!
else if gameMenuOption is equal to "Sell Assets" then
    set gameMulla to gameMulla + gameAssets
else
    error -128
end if

if 语句不起作用!我已经研究了 IF 循环在 applescript 和运算符上的语法,并一遍又一遍地重新阅读我的代码,但我没有看到任何错误!当用户 select 一个选项时,它只是 returns 我故意写的 -128 错误但它不应该这样做......我什至用 display dialog 测试了它:

--> User enters: Sell Assets
display dialog gameMenuOption
--> Returns: Sell Assets

但是当我这样做时:

display dialog gameMenuOption = "Sell Assets"
--> Returns: False

此外,我认为我需要将其转换为字符串,但没有成功:
Expected expression but found “to”.

请帮帮我!

来自文档:

The choose from list command can optionally let the user choose multiple items by setting the multiple selections allowed parameter to true. For this reason, the result of the command is always a list of selected strings.

所以结果永远不会是"Shop"。可能是 {"Shop"}.

示例:

set simMenu to {"Shop", "Sell Assets"}
set gameMenuOption to choose from list simMenu with prompt "Blah blah blah"
if gameMenuOption = {"Shop"} then
    display dialog "It worked" // the dialog appears
end if

或者(这可能更常见)你可以说

if item 1 of gameMenuOption = "Shop"