Fractal.Create (Civ5 API)

From Civilization Modding Wiki
Jump to: navigation, search

This page is a part of the Lua and UI Reference (Civ5).


Function.png This function is a member of Fractal.

This is a static method, invoke it with a dot.
Used to create a 2D-array of random values using [Fractal] (insert wikipedia link here) math.


Usage

Fractal Fractal.Create(int width, int height, int grain, table fractalFlags, int xExponent, int yExponent)


Returned Value

Returns an instance of Fractal.

Parameters

width: The width of the 2D array to create.
height: The height of the 2D array to create.
grain: Amount of grain to add to fractal. 0 is no grain (smooth), 7 is lots of grain (jagged).
fractalFlags: A table that holds certain additional options used in creating the fractal. See below.
xExponent: Width resolution of the fractal. Higher values will produce sharper fractals, while lower values will produce blurry ones.
yExponent: Height resolution of the fractal.

A note about fractal exponents from MultilayeredFractal.lua:

FracXExp is the width of the source fractal.

FracYExp is the height of the source fractal. These exponents are raised to powers of two. So a value of FracXExp = 7 means 2^7, which would be 128 units wide. FracXExp = 6 would be only 64

units wide. FracYExp works the same way.

Fractal Flags

boolean FRAC_WRAP_X: Whether or not the fractal should wrap around the X axis.
boolean FRAC_WRAP_Y: ???
boolean FRAC_POLAR: ???

Source code samples

Too many occurences. Only 50 out of 130 are listed.

Amazon_XP.lua (G&K)

DLC/Expansion/Maps/Amazon_XP.lua
0069
local peaksFrac = Fractal.Create(iW, iH, grain_amount + 1, {}, 6, 6);
0269
local grass_check = Fractal.Create(iW, iH, 5, {}, 6, 6);
0270
local desert_check = Fractal.Create(iW, iH, 4, {}, 6, 6);
0366
local marshes = Fractal.Create(iW, iH, forest_grain, {}, 6, 6);
0367
local forests = Fractal.Create(iW, iH, forest_grain, {}, 6, 6);


Boreal.lua (G&K)

DLC/Expansion/Maps/Boreal.lua
0126
local lakesFrac = Fractal.Create(iW, iH, 2, iFlags, -1, -1);
0127
local hillsFrac = Fractal.Create(iW, iH, grain, iFlags, -1, -1);
0128
local mountainsFrac = Fractal.Create(iW, iH, grain, iFlags, -1, -1);
0181
local snowFrac = Fractal.Create(iW, iH, 3, iFlags, -1, -1);
0182
local snowFrac2 = Fractal.Create(iW, 1 + math.floor(iH * 0.4), 2, iFlags, 7, 6);
0183
local plainsFrac = Fractal.Create(iW, iH, 4, iFlags, -1, -1);


ContinentsWorld.lua

Gameplay/Lua/ContinentsWorld.lua
0102
self.mountainsFrac = Fractal.Create(self.iNumPlotsX, self.iNumPlotsY, 4, self.iFlags, self.fracXExp, self.fracYExp);


Europe.lua (G&K)

DLC/Expansion/Maps/Europe.lua
0440
local snow_frac = Fractal.Create(iW, iH, grain_amount + 1, iFlags, -1, -1);
0441
local tundra_frac = Fractal.Create(iW, iH, grain_amount + 1, iFlags, -1, -1);
0442
local grass_frac = Fractal.Create(iW, iH, grain_amount, iFlags, -1, -1);


FeatureGenerator.lua (G&K)

DLC/Expansion/Gameplay/Lua/FeatureGenerator.lua
0128
self.jungles      = Fractal.Create(width, height, self.jungle_grain, self.fractalFlags, self.fracXExp, self.fracYExp);
0129
self.forests      = Fractal.Create(width, height, self.forest_grain, self.fractalFlags, self.fracXExp, self.fracYExp);
0130
self.forestclumps   = Fractal.Create(width, height, self.clump_grain, self.fractalFlags, self.fracXExp, self.fracYExp);


FractalWorld.lua

Gameplay/Lua/FractalWorld.lua
0059
self.riftsFrac = Fractal.Create(self.iNumPlotsX, self.iNumPlotsY, rift_grain, {}, self.fracXExp, self.fracYExp);
0062
self.continentsFrac = Fractal.Create(self.iNumPlotsX, self.iNumPlotsY, continent_grain, fracFlags, self.fracXExp, self.fracYExp);
0662
self.hillsFrac = Fractal.Create(self.iNumPlotsX, self.iNumPlotsY, grain, self.iFlags, self.fracXExp, self.fracYExp);
0663
self.mountainsFrac = Fractal.Create(self.iNumPlotsX, self.iNumPlotsY, grain, self.iFlags, self.fracXExp, self.fracYExp);


Great_Plains.lua

Maps/Great_Plains.lua
0069
local hillsFrac = Fractal.Create(iW, iH, grain_amount, iFlags, 6, 6);
0070
local peaksFrac = Fractal.Create(iW, iH, grain_amount + 1, iFlags, 6, 6);
0071
local regionsFrac = Fractal.Create(iW, iH, grain_amount, iFlags, 6, 6);
0361
local rocky = Fractal.Create(iW, iH, grain_amount, iFlags, -1, -1);
0362
local plains = Fractal.Create(iW, iH, grain_amount + 1, iFlags, -1, -1);
0363
local east = Fractal.Create(iW, iH, grain_amount, iFlags, -1, -1);
0364
local variation = Fractal.Create(iW, iH, grain_amount, iFlags, -1, -1);
0492
local forests = Fractal.Create(iW, iH, forest_grain, iFlags, fracXExp, fracYExp);
1490
local herds = Fractal.Create(iW, iH, 7, {}, -1, -1)
1491
local iHerdsClumps = herds:GetHeight(3)


Hemispheres.lua (G&K)

DLC/Expansion/Maps/Hemispheres.lua
0820
local regionHillsFrac = Fractal.Create(iW, iH, 5, {}, 7, 7);
0821
local regionPeaksFrac = Fractal.Create(iW, iH, 6, {}, 7, 7);


Highlands.lua

Maps/Highlands.lua
0169
local terrainFrac = Fractal.Create(iW, iH, grain, iFlags, -1, -1);
0170
local lakesFrac = Fractal.Create(iW, iH, lake_grain, iFlags, -1, -1);
0171
local mountain_passFrac = Fractal.Create(iW, iH, grain, iFlags, -1, -1);


InlandSea.lua

Maps/InlandSea.lua
0073
local seaFrac = Fractal.Create(iWidth, iHeight, grain, fracFlags, -1, -1)
0074
local seaThreshold = seaFrac:GetHeight(47);


Lakes.lua

Maps/Lakes.lua
0100
local lakesFrac = Fractal.Create(iW, iH, lake_grain, fracFlags, -1, -1);


MultilayeredFractal.lua (G&K)

DLC/Expansion/Gameplay/Lua/MultilayeredFractal.lua
0338
local riftsFrac = Fractal.Create(iRegionWidth, iRegionHeight, iRiftGrain, {}, iRegionFracXExp, iRegionFracYExp);
0341
regionContinentsFrac = Fractal.Create(iRegionWidth, iRegionHeight, iRegionGrain, iRegionPlotFlags, iRegionFracXExp, iRegionFracYExp);
0350
local regionHillsFrac = Fractal.Create(iRegionWidth, iRegionHeight, iRegionHillsGrain, iRegionTerrainFlags, iRegionFracXExp, iRegionFracYExp);
0351
local regionPeaksFrac = Fractal.Create(iRegionWidth, iRegionHeight, iRegionHillsGrain + 1, iRegionTerrainFlags, iRegionFracXExp, iRegionFracYExp);
0708
self.hillsFrac = Fractal.Create(self.iW, self.iH, grain_amount, self.iTerrainFlags, fracXExp, fracYExp);
0709
self.mountainsFrac = Fractal.Create(self.iW, self.iH, grain_amount, self.iTerrainFlags, fracXExp, fracYExp);


North_vs_South.lua

Maps/North_vs_South.lua
0090
local lakesFrac = Fractal.Create(iW, iH, lake_grain, fracFlags, 6, 6);


Oval.lua

Maps/Oval.lua
0100
local baysFrac = Fractal.Create(iW, iH, 3, fracFlags, -1, -1);


Skirmish.lua

Maps/Skirmish.lua
0146
local terrainFrac = Fractal.Create(iW, iH, grain, fracFlags, -1, -1);
0151
local hillsFrac = Fractal.Create(iW, iH, grain, fracFlags, -1, -1);


TerrainGenerator.lua

Gameplay/Lua/TerrainGenerator.lua
0108
self.deserts = Fractal.Create(   self.iWidth, self.iHeight,
0109
self.grain_amount, self.fractalFlags,
0110
self.fracXExp, self.fracYExp);
0115
self.plains = Fractal.Create(   self.iWidth, self.iHeight,
0116
self.grain_amount, self.fractalFlags,
0117
self.fracXExp, self.fracYExp);



The initial version of this page was created by the Civ5 API Bot, see the Civ5 API Reference FAQ. Some of the texts come from the 2kgames' wiki and most of code samples are copyrighted to Firaxis.
Functions' signatures were either copied from the 2kgames' wiki, or infered from the Lua source files and the binaries. Errors are possible.
Contributors may find help in the Contributors guide to the Civ5 API.