2014-06-30 121 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