我一直在玩applescript,我正在制作一个文本版本的口袋妖怪。我有一个从列表中选择和一个 if 语句来启动一个显示对话框。当你按下运行它应该说“你不能从训练家战斗中逃跑”,但显示对话框永远不会打开。我看不出有什么问题。我一直在搜索谷歌,但找不到解决方案
这是代码
set userStarter to "undefined"
set starterHP to "undefined"
set starterLV to 5
set starters to {"Charmander", "Bulbasor", "Squirtle", "Pikachu"}
set userName to "undefined"
on battle(traner)
display dialog traner & " wants to battle!" buttons {"Next"}
set battleMenu to {"Attack", "Bag", "Run"}
set temp to {choose from list battleMenu}
if temp is "Run" then
display dialog "You cannot run from a trainer battle" buttons {"Ok"}
end if
end battle
display dialog "Welcome to text based Pokemon!" buttons {"Play", "Quit"}
if the button returned of the result is "Play" then
set temp to display dialog "What is your name?" default answer "Ash" buttons {"Submit"}
set userName to text returned of temp
set userStarter to {choose from list starters}
display dialog "Oak: Okay " & userName & " here is your " & userStarter buttons {"Next"}
display dialog "Gary: Hey, lets battle!" buttons {"Battle"}
battle("Gary")
end if
这是日志
tell application "AppleScript Editor"
display dialog "Welcome to text based Pokemon!" buttons {"Play", "Quit"}
--> {button returned:"Play"}
display dialog "What is your name?" default answer "Ash" buttons {"Submit"}
--> {text returned:"Ash", button returned:"Submit"}
choose from list {"Charmander", "Bulbasor", "Squirtle", "Pikachu"}
--> {"Pikachu"}
display dialog "Oak: Okay Ash here is your Pikachu" buttons {"Next"}
--> {button returned:"Next"}
display dialog "Gary: Hey, lets battle!" buttons {"Battle"}
--> {button returned:"Battle"}
display dialog "Gary wants to battle!" buttons {"Next"}
--> {button returned:"Next"}
choose from list {"Attack", "Bag", "Run"}
--> {"Run"}
end tell