JavaScript Voxel Building Tutorial - Part 4 (Doorway Construction)


#1
  • This tutorial will help you build a doorway on the ground level on your respective plot. Throughout this example I will use my specific coordinates. Simply plug in your respective coordinates to begin your build.

Step 1: Doorway Construction

  • Here is an example of how to create a doorway on the ground level of your plot.

    // Function to make a doorway on the ground position of your plot.
    function makeDoorway()
    {
    // Create variables and set to initial voxel build position.
    var x = 6271.5;
    var y = 192;
    var z = 7098.5;

      // Erase surrounding wall voxels to allow avitars to fit through the door. 
      Voxels.eraseVoxel(6272, 192, 7099, 1);
      Voxels.eraseVoxel(6272, 192, 7100, 1);
      Voxels.eraseVoxel(6272, 192, 7101, 1);
      Voxels.eraseVoxel(6272, 193, 7099, 1);
      Voxels.eraseVoxel(6272, 193, 7100, 1);
      Voxels.eraseVoxel(6272, 193, 7101, 1);
      Voxels.eraseVoxel(6272, 194, 7099, 1);
      Voxels.eraseVoxel(6272, 194, 7100, 1);
      Voxels.eraseVoxel(6272, 194, 7101, 1);
      
      // Make new structural support to the wall that was partitally torn-out.
      Voxels.setVoxel(6272, 193, 7098, 1, 255, 100, 0);
      Voxels.setVoxel(6272, 193, 7102, 1, 255, 100, 0);
      
      // Create outer left door frame up the Y axis.
      while (y <= 194.5)
      {
      	Voxels.setVoxel(x, y, z, .5, 245, 12, 90);
      	y = y + .5;
      }
      
      // Create outer top door frame across the Z axis.
      while (z <= 7102)
      {
      	Voxels.setVoxel(x, y, z, .5, 245, 12, 90);
      	z = z + .5;
      }
      
      // Set Y and Z variables back to your new voxel build position.
      y = 192;
      z = 7102;
      
      // Create outer right door frame down the Y axis.
      while (y <= 194.5)
      {
      	Voxels.setVoxel(x, y, z, .5, 245, 12, 90);
      	y = y + .5;
      }
      
      // Stop script.
      Script.stop();
    

    }

    Script.update.connect(makeDoorway);