2014-06-30 164 views
0

不確定。基本上我希望用戶點擊對話。如果NPC有250,重複25次。無論NPC重複/ 10次。根據用戶輸入重複次數

它不斷給我rtimes未定義的錯誤,並rtimes應在if語句

代碼來定義:

(choose from list {"50", "100", "200", "250"} ¬ 
with prompt "How many does the NPC have?") 
set list_answer to result 
set tom to result 
set rtimes to (tom/10) 

if tom is equal to 50 then 
    set rtimes to 5 
end if 

if tom is equal to 100 then 
    set rtimes to 10 
end if 

if tom is equal to 200 then 
    set rtimes to 20 
end if 

if tom is equal to 250 then 
    set rtimes to 25 
end if 

display dialog tom 
display dialog rtimes 

回答

2

,我從你的腳本沒有錯誤,但這裏是一個更簡明的方式來寫你想要實現的:

set tom to (choose from list {"50", "100", "200", "250"} ¬ 
    with prompt "How many does the NPC have?") 
set rtimes to (tom/10) as integer 
display dialog "tom: " & tom & return & "rtimes: " & rtimes