Adding and removing specific triangles ?

I’m trying to create procedural terrain made out of cubes. I have and array of cubes and i’m trying make each cube check if there’s air next to it, if there is this script will create a side as needed, but it doesn’t work for some reason. Am I doing something wrong ? I need to add a face to an already existing mesh. Here’s my script bellow.

`public function UpdateChunkBlocks(){

var vertices : Vector3[];
		
var uvs : Vector2[];

var newMesh : Mesh;

newMesh = transform.GetComponent(MeshFilter).mesh;

//newMesh = newMesh.mesh;

newMesh = new Mesh(); 

var p1 : Vector3 = new Vector3(.5 + transform.position.x, .5 + transform.position.y, .5 + transform.position.z);

var p2 : Vector3 = new Vector3(.5 + transform.position.x, .5 + transform.position.y, -.5 + transform.position.z);

var p3 : Vector3 = new Vector3(-.5 + transform.position.x, .5 + transform.position.y, -.5 + transform.position.z); 

var p4 : Vector3 = new Vector3(-.5 + transform.position.x, .5 + transform.position.y, .5 + transform.position.z);

var p5 : Vector3 = new Vector3(.5 + transform.position.x, -.5 + transform.position.y, .5 + transform.position.z);

var p6 : Vector3 = new Vector3(.5 + transform.position.x, -.5 + transform.position.y, -.5 + transform.position.z);

var p7 : Vector3 = new Vector3(-.5 + transform.position.x, -.5 + transform.position.y, -.5 + transform.position.z);

var p8 : Vector3 = new Vector3(-.5 + transform.position.x, -.5 + transform.position.y, .5 + transform.position.z);



for (var c = 0; c <= 4096; c++) {
	
	for (var b = 0; b <= 4096; b++){ 
		
		var cBlock;
		cBlock = c; //every block in the array
		
		var bBlock;//every block that is being checked
		bBlock = b;
		
			if(bBlock.Position == cBlock.Position + Vector3(0, 1, 0) && bBlock.Type == "air"){

			   	vertices[0] = p1;
			    
			    vertices[1] = p2;
			    
			    vertices[2] = p3;
			    
			    vertices[3] = p3; 
				
				uvs[0] = new Vector2(0, .5); 
    
    			uvs[1] = new Vector2(.5, .5); 
    
   			 	uvs[2] = new Vector2(.5,0); 
    
    			uvs[3] = new Vector2(0, 0); 
				
				newMesh.triangles += [0, 1, 2, 0, 2, 3];
				
				newMesh.vertices += vertices;
				
				newMesh.triangles += [0, 1, 2, 0, 2, 3];      
				
				newMesh.uv += uvs;
			}
		
	}

}

newMesh.RecalculateNormals(); 
newMesh.RecalculateBounds();

} I get this error message every time. MissingFieldException: Field 'System.Int32.Position' not found. Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.FindExtension (IEnumerable1 candidates)
Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.Create (SetOrGet gos)
Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.CreateGetter ()
Boo.Lang.Runtime.RuntimeServices.DoCreatePropGetDispatcher (System.Object target, System.Type type, System.String name)
Boo.Lang.Runtime.RuntimeServices.CreatePropGetDispatcher (System.Object target, System.String name)
Boo.Lang.Runtime.RuntimeServices+c__AnonStorey14.<>m__9 ()
Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name)
UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name)

cBlock and bBlock are type int in your case. type int has no method Position.

My recommendation: use C# and you will get error like that during compile time. Or add “pragma strict” (or something like that) to your JS files.