Hey there. Having another little syntax problem again regarding nested IF..THEN loops. I figured you guys would be able to tell me what's up. What i'm attempting to code is a simple routine that would compare randomly generated X,Y,Z map coordinates against a set of 20 pre-fixed coordinates. For example, let's say this is a game where the planet earth is assigned a fixed coordinate of X=1, Y=1 and Z=1. Now let's say, I wanted to compare the X,Y,Z coordinates of a new, randomly generated planet on my map against the fixed coordinate of planet earth, to make sure the randomly generated planet doesn't occupy the same coordinates as the fixed planet. Normally, i'm used to doing this in a nested IF...Then...Else scenario. Here's what i'm doing:
Variable J is equal to the total number of random planets to compare to fixed planet locations. Variable I is equal to the number of fixed planets to compare in the loop. Gsize# is the number of random planets in the galaxy. Coord# is the X,Y,Z DIM array for the fixed planet locations. Rcoord# is the X,Y,Z, DIM array for the random planets.
Compare:
For J=1 to gsize#
for I =1 to 20
if rcoord#(gsize#,1)=coord#(I,1) then
if rcoord#(gsize#,2)=coord#(I,2) then
if rcoord#(gsize#,3)=coord#(I,3) then
rcoord#(gsize#,1)=RND(1000)
rcoord#(gsize#,2)=RND(1000)
rcoord#(gsize#,3)=RND(1000)
endif
else
Next I
Next J
The reason for using the nested IF..Then statements is so that IF condition #1 = true then if condition #2=true then if condition #3=true, regenerate the random number X,Y,Z coordinates, else do nothing and proceed to comparing the coordinates of the next planet.
Apparently, Darkbasic doesn't handle nested IF...Then statements that well. Can anyone think of a solution that would accomplish the same thing in Darkbasic?
Yes.... no... wait!