Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var caveBlockColor = 0x6E6E6E; //Sets the color of the block to generate, in this case grey
- var caveRadiusMin = 2; //The minimum radius of a section of cave
- var caveRadiusMax = 4; //The maximum radius of a section of cave
- var volatility1 = 4; //Determines the randomness of the cave
- var volatility2 = 2; //Determines the randomness of the cave
- var caveLength = 100; //The maximum length of the cave
- var caveStartX = 0; //The x-coord to start generating at.
- var caveStartY = 0; //The y-coord to start generating at.
- var caveStartZ = 0; //The z-coord to start generating at.
- var flatCave = false; //If true the cave's z axis will not be adjusted
- var passes = 2; //How many passes to perform. Each pass generates a separate cave.
- var randomizeVolatility = true; //If true to volatility is randomised as the cave is generated.
- passes = Math.abs(passes);
- caveLength = Math.abs(caveLength);
- var x = caveStartX;
- var y = caveStartY;
- var z = caveStartZ;
- var radius = random(caveRadiusMin,caveRadiusMax);
- var length = 0;
- var xAngle = random(-1*altVolatility,altVolatility);
- var yAngle = random(-1*altVolatility,altVolatility);
- var zAngle = random(-1*altVolatility,altVolatility);
- var currAngleDistance = 1;
- var currPasses = 0;
- var caveVolatility = volatility1;
- var altVolatility = volatility2;
- while (currPasses < passes){
- if(randomizeVolatility){
- caveVolatility += random(-1,1);
- altVolatility += random(-1,1);
- }
- x = caveStartX;
- y = caveStartY;
- z = caveStartZ;
- radius = random(caveRadiusMin,caveRadiusMax);
- length = 0;
- xAngle = random(-1*altVolatility,altVolatility);
- yAngle = random(-1*altVolatility,altVolatility);
- zAngle = random(-1*altVolatility,altVolatility);
- currAngleDistance = 1;
- while (length<caveLength){
- caveVolatility = Math.min(radius, volatility1);
- altVolatility = Math.min(radius, volatility2);
- gProject.putBlocks(ball(x,y,z,radius,caveBlockColor));
- if(currAngleDistance>0){
- x += xAngle;
- y += yAngle;
- if(!flatCave){
- z = Math.max(z + zAngle, radius + 1);
- }else{
- z = radius+caveStartZ;
- }
- currAngleDistance--;
- length++;
- radius = random(caveRadiusMin,caveRadiusMax);
- }else{
- currAngleDistance = random(1, Math.abs(caveVolatility - radius));
- xAngle = random(-1*altVolatility,altVolatility);
- yAngle = random(-1*altVolatility,altVolatility);
- if(z>currAngleDistance){
- zAngle = random(-1*altVolatility,altVolatility);
- }else{
- zAngle = 1;
- }
- }
- }
- currPasses++;
- }
- function random(min, max){
- return Math.round(Math.random() * (max - min)) + min;
- }
- cullProjectOccludedBlocks();
- gEditor.requestRender();
Add Comment
Please, Sign In to add comment