So I'm setting up random generation of worlds in batch. For this, I need to put an if statement into an array. However, it does not seem to recognize that I'm trying to put a variable inside a variable.
So far, I've tried using !, %%, and % for the variables. I also tried removing the if statements, and although the error stopped, the numbers still got below 0 and above 15.
This is the code I currently have. i believe that the problem is in the 2 if statements on lines 8 and 9, as without them
echo Generating biomes...
rem 0x 0y
set /A biomenum0x0y = %RANDOM% * 16 / 32768 + 1
rem The rest!
for %%x in (neg1 0 1) do (
for %%y in (neg1 0 1) do (
set /A nextbiomenum = !RANDOM! * 4 / 32768 - 1, biomenum[%%x][%%y] = biomenum[0][0] + nextbiomenum %% 2
if %%biomenum[%x%][%y%]%% LSS 0 set %%biomenum[%x%][%y%]%% EQU "0"
if %%biomenum[%x%][%y%]%% GTR 15 set %%biomenum[%x%][%y%]%% EQU "15"
)
)
echo %biomenum[neg1][neg1]% is the biome for -1,-1
echo %biomenum[neg1][0]% is the biome for -1, 0
echo %biomenum[neg1][1]% is the biome for -1, 1
echo %biomenum[0][neg1]% is the biome for 0, -1
echo %biomenum[0][0]% is the biome for 0, 0 -the starting chunk-
echo %biomenum[0][1]% is the biome for 0, 1
echo %biomenum[1][neg1]% is the biome for 1, -1
echo %biomenum[1][0]% is the biome for 1, 0
echo %biomenum[1][1]% is the biome for 1, 1
What it should be doing is keeping the number between 0 and 15, however sometimes it goes to -1 and 16. It also prints out Environment variable %biomenum[][]% EQU "15" not defined
9 times.
Aucun commentaire:
Enregistrer un commentaire