0

This batch script always gives the answer "You make some 0" instead of other options. What did I do wrong here?

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

2 Answers 2

2

need to use % to refer back to the contents of a variable, this way

     if %foodcalc%==1 echo one!
Sign up to request clarification or add additional context in comments.

Comments

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 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.