#### TNL Example Script #### # beginning a line with # makes a comment, obviously # = names an expression so you can use it easily later # # most functions take an X,Y,Z and return a value, but in TNL you do not # normally reference X,Y,Z and the value directly (since those depend # on which section of map is being generated, which is controlled externally). # Rather, you chain functions together to specify how X,Y,Z and the result value # are transformed. e.g. # perlin * 2 # - will double the return value from perlin # xf( x * 2, y * 2, z, perlin ) # - will double the X and Y values that are given to perlin # # Constant numbers can be represented in standard decimal format: # 23, -4.75 +12.3333 # # Outputs can be added, subtracted, multiplied, and divided using infix # operators: # 2 * 3, perlin * 8 - 2.1, max(0,perlin) - 0.5 # # Some functions only take constants for certain arguments. e.g. you may # pass (4) as the x, y arguments to scale-in, but not (perlin). # # Notes about some basic functions: # x, y, z # - the values of the X, Y, and Z inputs # perlin # - the standard 3-dimensional perlin noise function # xf( , , , ) # - transforms X, Y, and Z using the transforms given before passing # to , which is an arbitrary expression # scale-in( , , , # - a special case of xf that scales X, Y, and Z by the specified CONSTANT # amounts # translates-in( , , , # - a special case of xf that translates X, Y, and Z by the specified # CONSTANT amounts # min( , ) # - takes the lower of the outputs of a and b for each point (X,Y,Z) of input # max( , ) # - takes the higher of the outputs of a and b for each point (X,Y,Z) of input # ridge( , , ) # - 'folds up' the value function so that the output fits between # and at every point # fractal( , # , , # , , # , ) # - documentation pending, see if you can figure it. # You can name an expression with the syntax " = ;": basis = perlin; upper-base = 100 + fractal(7,0.5,1,2.2,-2,0,basis); upper-top = 105 + fractal(5,3 ,1,2,-2,0,basis); lower-base = 40 + fractal(7,0.7,1,2,-2,0,basis); lower-top = 55 + fractal(5,4 ,1,2,-2,0,basis); coolperl = perlin * min(2,max(0.2,scale-in( 0.1, 0.1, 0.1, perlin ) * 2)); sand-height = fractal( 12, 8, 4, 2, 1.4, 1, coolperl ); max-ground = upper-top; min-ground = lower-base; mountain-height = max(min-ground,min(max-ground, 32 + fractal(4,48,48,2,1.5,-1,perlin) * max(0.4,fractal(4,512,1.5,1,1,-7,perlin)) )); coal-height = fractal(3,6,3,3,3,-1,perlin); var-height = fractal(1,5,2,2,1,-23,perlin); layered-terrain( #layer( materials.water, 0, 44 ), # Basic terrain: #layer( materials.sand, 0, min(max-ground,41 + sand-height) ), #layer( materials.dirt, 0, min(max-ground,40 + sand-height * 1.1 + fractal(3,16,12,3,1,1,coolperl)) ), #layer( materials.dirt, 0, min(max-ground,mountain-height + 4 + fractal(4,6,6,3,3,1,coolperl)) ), #layer( materials.stone, 0, mountain-height ), # Ores: #layer( materials.coal-ore, lower-base - fractal(3,6,3,3,3,-1,perlin), lower-top - 2 + fractal(1,5,2,2,1,-23,perlin)), #layer( materials.coal-ore, 64 + coal-height, min(lower-top, 64 + coal-height + 1 + var-height) ), #layer( materials.iron-ore, lower-top - 20 + fractal(2,5,3,3,3,-23,perlin), lower-top - 21 ), #layer( materials.gold-ore, 20 + coal-height, 20.5 + coal-height + var-height ), #layer( materials.diamond-ore, 10 + translate-in(0,0,10,coal-height), 10 + translate-in(0,0,10,coal-height + var-height) ), #layer( materials.redstone-ore, 3 + translate-in(0,0,20,coal-height ), 3 + translate-in(0,0,20,coal-height + var-height) ), # Caves: #layer( materials.air, 26 + fractal(3,5,3,3,3,1,perlin), min(mountain-height - 2,26 + fractal(3,5,5,3,3,-2,perlin)) ), #layer( materials.air, 46 + fractal(3,5,3,3,3,-3,perlin), min(mountain-height - 2,46 + fractal(3,5,5,3,3,-4,perlin)) ), # Cave with lava: #layer( materials.air, 16 + fractal(3,5,3,3,3,-7,perlin), min(mountain-height - 2,20 + fractal(3,5,3,3,3,-7,perlin)) ), #layer( materials.lava, 16 + fractal(3,5,3,3,3,-7,perlin), min(16, min(mountain-height - 2,20 + fractal(3,5,4,3,3,-7,perlin)) )), # Upper islands layer( materials.grass, upper-base, upper-top), layer( materials.dirt, upper-base, upper-top - 1), layer( materials.stone, upper-base, upper-top - 5), # Lower islands layer( materials.grass, lower-base, lower-top), layer( materials.dirt, lower-base, lower-top - 1), layer( materials.stone, lower-base, lower-top - 5), #layer( materials.coal-ore, lower-base - fractal(3,6,3,3,3,-1,perlin), lower-top - 2 + fractal(1,5,2,2,1,-23,perlin)), layer( materials.coal-ore, upper-base + 25 + coal-height, min(upper-top, 120 + coal-height + var-height) ), layer( materials.iron-ore, upper-base + 5 - fractal(2,5,3,3,3,-23,perlin), upper-top - 11 - fractal(2,5,3,3,3,-23,perlin) ), layer( materials.gold-ore, lower-base + 5 + coal-height, lower-top - 20 - coal-height - var-height ), layer( materials.diamond-ore, lower-base + 15 + translate-in(0,0,10,coal-height), lower-top - 25 + translate-in(0,0,10,coal-height + var-height) ), layer( materials.redstone-ore, lower-base + translate-in(0,0,20,coal-height ), 15 + translate-in(0,0,20,coal-height + var-height) ), #layer( materials.diamond-ore, lower-base + mountain-height + coal-height, lower-top - mountain-height - var-height), #layer( materials.bedrock, 0, 1 ), grassifier, tree-populator( tree-types.pine, fractal( 3, 100, 0.003, 2, 2, 3, perlin )), tree-populator( tree-types.round, fractal( 3, 50, 0.003, 2, 2, -3, perlin )), lighter, # flag-populated, );