1
我一直在玩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
哦,我使用AppleScript搞亂,並計劃做文字口袋妖怪太:DI才發現這個問題,通過搜索「的AppleScript按鈕」 –