这个批处理脚本总是给出答案“你做一些0”而不是其他选项。 我在这里做错了什么?
set /a foodcalc=0
set /a dish=0
set /a food1=1
set /a food2=2
set /a food3=3
set /a food4=4
SET /a foodcalc=4*%random%/32768+1
IF foodcalc==1 set /a dish food1
IF foodcalc==2 set /a dish food2
IF foodcalc==3 set /a dish food3
IF foodcalc==4 set /a dish food4
echo You make some %dish%.
ping localhost -n 3 >nul
goto actualgame
答案 0 :(得分:2)
需要使用%来引用变量的内容,这样
if %foodcalc%==1 echo one!
答案 1 :(得分:1)
IF %foodcalc%==1 set /a dish=food1
IF %foodcalc%==2 set /a dish=food2
IF %foodcalc%==3 set /a dish=food3
IF %foodcalc%==4 set /a dish=food4