array maps

Blitz3D Forums/Blitz3D Beginners Area/array maps

Here is some code (that is not working)...I am wondering why?
(the code does not "see" other units)
Function find_open_build_spot(start_x,start_z)
Local h = 0
	Repeat
		If h > build_patternSize Then Return 0
		If (start_x < mapWidth*tilesize) And (start_x > 0) And (start_z < mapHeight*tilesize) And (start_z > 0) Then
			If walkability(Floor(start_x/tilesize),Floor(start_z/tilesize)) = walkable Then
				If unit_walkability(Floor(start_x/tilesize),Floor(start_z/tilesize)) = 0 Then 
					Return h-1
				End If
			EndIf
		EndIf
		start_x = start_x + build_pattern(h,1)	;build pattern h is the pointer to the next coords to try
		start_z = start_z + build_pattern(h,2)  ;relative to (x,y)...basically a spiral
		h = h + 1
	Forever
End Function



and in the main loop

for unit.unit = each unit
For i = -5 To 5
	For h = -5 To 5
		tempx = unit\xLoc/tilesize
		tempz = unit\zLoc/tilesize
		If i+tempx > 0 And i+tempx < mapWidth And h+tempz > 0 And h+tempz < mapHeight Then 
			If unit_walkability(i+tempx,h+tempz) = unit\entity Then 
				unit_walkability(i+tempx,h+tempz) = 0
			EndIf
		EndIf
	Next
Next
unit_walkability(unit\xLoc/tilesize,unit\zLoc/tilesize) = unit\entity
next


It is important to note that the build_pattern(x,y) point to the next cell coordinates