Batch Problems (making a dice)

119 Views Asked by At

This is my code in batch:

:Dice
set /a roll=(%random% %% 6) + 1
set /a on=%on%+%roll%
if %on%>19 goto DiceOver19
if %on%<20 goto Camp1_1

I'm trying to make a monopoly and i have almost everything setup. I've been trying to figure this out but i just cant. Everything goes fine until i select "Roll the dice". ^^Above is the code for the dice.

The program just exits as soon as i go to Dice, can someone help?

EDIT: Fixed, now works fine.

1

There are 1 best solutions below

0
On

Despite you having solved your own problem with the help of comments, I have added this reply which although technically not a direct response to your question includes a comparison operator and a standard roll loop which allows for a roll again feature in the event of rolling a double six. (I hope it at least benefits others)

@Echo Off
:Roll
Set "dice=0"
:Loop
Set/A "die1=%random%%%6+1"
Set/A "die2=%random%%%6+1"
Echo( %die1% + %die2%
Set/A "dice=die1+die2+dice"
Set/A "mod=dice%%12"
If %mod% Equ 0 (Echo= Double 6 rolls again & GoTo Loop)
Echo( Total=%dice%
:Next
Timeout 3 1>Nul

Note this is for information only.