Code: Select all
set /a rngn=%random% %% 25
Then a big loop that will set a variable depending on how many times it has cycled through the loop.
The slot variable has already been declared, and equals 1.
Code: Select all
:setvars
set /a rngn=%random% %% 25
echo %rngn%
IF /i %rngn%==0 (
set itm%slot%=stick
)
IF /i %rngn%==1 (
set itm%slot%=log
)
IF /i %rngn%==2 (
set itm%slot%=rock
)
IF /i %rngn%==3 (
set itm%slot%=flint
)
IF /i %rngn%==4 (
set itm%slot%=steel_fragment
)
IF /i %rngn%==5 (
set itm%slot%=rope_fragment
)
IF /i %rngn%==6 (
set itm%slot%=axe
)
IF /i %rngn%==7 (
set itm%slot%=log
)
IF /i %rngn%==8 (
set itm%slot%=cloth_fragment
)
IF /i %rngn%==9 (
set itm%slot%=tunic
)
IF /i %rngn%==10 (
set itm%slot%=pants
)
IF /i %rngn% GEQ 10 (
goto af
)
set /a slot= %slot% +1
:af
echo !itm%slot%!
set /a timer= %timer% +1
IF %timer% GEQ 10 (
goto check
) ELSE (
goto setvars
)
:check
I didn't use a for loop becuase really it wouldn't have been much shorter. I do know that the loop works though, and it isn't an issue.
Basically it's a random item generator, which generates a number, which is recognized as an item, which is represented by a string. Any number it generates that isn't LEQ 10 is not considered an item, and those values are only generated for a chance of not getting an item.
Now when i try to
Code: Select all
echo !itm%slot%!
Code: Select all
ECHO is on.
It should be returning a string that is associated with the random number assigned to that variable.
Is this a problem with my
Code: Select all
set itm%slot%=string
Code: Select all
echo !itm%slot%!
Feel free to point out any more errors with my code, but I'd prefer to not have to rewrite that whole loop.