When MapArray doesn't have a certain number?

BlitzMax Forums/BlitzMax Beginners Area/When MapArray doesn't have a certain number?

Hi. Heres my problem.

I use my map editor to build a test map. I have a platform tile with 2 frames. Frame 0 is off and frame 1 is on.

The code below adds 1 to TTile.PlatformOnCount id there are any in the Factory Array.

Function FillTestFactoryMap() 
	For Local x:Int = 0 Until FMWIDTH
		For Local y:Int = 0 Until FMHeight
			FactoryMapTest[x, y]= TTile2.Create() 
			'FactoryMapTest[x,y] = ttile2
			FactoryMapTest[x, y].id = FactoryMap[x, y].id
			If FactoryMapTest[x, y].id = 1
				TTile2.PlatformOnCount:+1
			End If
		Next
	Next
End Function


Now I'm able to switch from on to off when my character stood on one or gone over one. This is not problem.

My problem is that I call this method "DetectChangeableTiles() " in the loop and it has this code in it.

			If FactoryMapTest[(x + 20) / 32, y / 32 + 1].id = 1 or FactoryMapTest[(x - 18) / 32 + 1, y / 32 + 1].id = 1
				TTile2.PlatformOnCount:-1
				FactoryMapTest[(x + 20) / 32, y / 32 + 1].id = 0 or FactoryMapTest[(x - 18) / 32 + 1, y / 32 + 1].id = 0
			
			End If


As you can see from the code, if my character walks on the tile and it = 1, it switches it to 0 and deducts 1 from TTile2.PlatformOnCount. Problem is though that TTile2.PlatformOnCount reduces by one as if it was in a loop. ie if I step on the tile instead of it deducting just 1 and stopping it continues to deduct 1.

I need for DetectChangeableTiles() to be in the main loop to detect the tiles in realtime.

Looking at my code is there anyway I can deduct only one from TTile2.PlatformOnCount
and only when the player is on the tile?

[edit] Or, if there is a way to detect when an array no longer contains a specific number that wouyld help me also.

Here's some screenies of what I'm working on.