Fractal.GetHeight (Civ5 API): Difference between revisions

From Civilization Modding Wiki
Jump to navigationJump to search
(Bot update)
 
 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:


{{TypeInfos5|Function.png|This function is a member of {{Type5|Fractal}}.<br/>
{{TypeInfos5|Function.png|This function is a member of {{Type5|Fractal}}.<br/>
This is an instance method, invoke it with a colon.
This is an instance method, invoke it with a colon.<br/>
Used to get the value of the 2D fractal array or the value of a certain percentage of the array.
}}
}}




=Usage=
=Usage=
<code>'''int''' Fractal:GetHeight<b>(</b>'''int''' x, '''int''' y = nil<b>)</b></code>
<code>'''int''' Fractal:GetHeight<b>(</b>'''int''' percentage<b>)</b></code>
 
'''Returned Value'''
:Returns the threshold value of a percentage of the fractal array. For example, if you pass in 70, this function will return a number close to 178, give or take some depending on the breakdown of the values in the array. Seems to have trouble with smaller arrays (<10x10).
'''Parameters'''
:{|
|-
|valign="top" style="padding-right:6px;"|percentage:
|valign="top"| ''A number between 0 and 100.''
|}
 
 
<code>'''int''' Fractal:GetHeight<b>(</b>'''int''' x, '''int''' y<b>)</b></code>




'''Returned Value'''
'''Returned Value'''
:No description available.
:Returns the value of the fractal array at coordinates X, Y. The value is between 0 and 255.
'''Parameters'''
'''Parameters'''
:{|
:{|
|-
|-
|valign="top" style="padding-right:6px;"|x:
|valign="top" style="padding-right:6px;"|x:
|valign="top"| ''No description available.''
|valign="top"| ''X coordinate of the value to retrieve.''
|-
|-
|valign="top" style="padding-right:6px;"|y:
|valign="top" style="padding-right:6px;"|y:
|valign="top"| ''No description available.''
|valign="top"| ''Y coordinate of the value to retrieve.''
|}
|}


=Source code samples=
=Source code samples=

Latest revision as of 09:29, 27 June 2014

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


Function.png This function is a member of Fractal.

This is an instance method, invoke it with a colon.
Used to get the value of the 2D fractal array or the value of a certain percentage of the array.


Usage

int Fractal:GetHeight(int percentage)

Returned Value

Returns the threshold value of a percentage of the fractal array. For example, if you pass in 70, this function will return a number close to 178, give or take some depending on the breakdown of the values in the array. Seems to have trouble with smaller arrays (<10x10).

Parameters

percentage: A number between 0 and 100.


int Fractal:GetHeight(int x, int y)


Returned Value

Returns the value of the fractal array at coordinates X, Y. The value is between 0 and 255.

Parameters

x: X coordinate of the value to retrieve.
y: Y coordinate of the value to retrieve.

Source code samples

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

Amazon_XP.lua (G&K)

DLC/Expansion/Maps/Amazon_XP.lua
0075
local iHillsTop2 = hillsFrac:GetHeight(80);
0080
local iPeakAndes = peaksFrac:GetHeight(63);
0271
local iAndesGrass = grass_check:GetHeight(65)
0272
local iAndesDesert = desert_check:GetHeight(75)
0312
local desertVal = desert_check:GetHeight(x, y);
0374
local iOpenLevel = open_lands:GetHeight(100 - iOpenPercent)
0376
local featureForest = FeatureTypes.FEATURE_FOREST;
0397
if plot:CanHaveFeature(featureForest) and forests:GetHeight(x, y) >= iForestLevel then
0418
if forests:GetHeight(x, y) >= iForestLevel then
0423
if marshes:GetHeight(x, y) >= iRiverMarshLevel then


Boreal.lua (G&K)

DLC/Expansion/Maps/Boreal.lua
0132
local iLakesThreshold = lakesFrac:GetHeight(94);
0138
local iHillsNearMountains = mountainsFrac:GetHeight(hillsNearMountains);
0139
local iMountainThreshold = mountainsFrac:GetHeight(mountains);
0148
local lakeVal = lakesFrac:GetHeight(x,y);
0153
local hillVal = hillsFrac:GetHeight(x, y);
0184
local iSnowThreshold = snowFrac:GetHeight(65);


ContinentsWorld.lua

Gameplay/Lua/ContinentsWorld.lua
0113
local iHillsTop2 = self.hillsFrac:GetHeight(75);
0114
local iHillsClumps = self.mountainsFrac:GetHeight(4);


Europe.lua (G&K)

DLC/Expansion/Maps/Europe.lua
0447
local iGrassTop = grass_frac:GetHeight(iGrassPercent);
0520
local val = snow_frac:GetHeight(x, y);


FeatureGenerator.lua (G&K)

DLC/Expansion/Gameplay/Lua/FeatureGenerator.lua
0257
local marsh_height = self.marsh:GetHeight(iX, iY)
0258
if(marsh_height >= self.iMarshLevel) then
0276
if (self.forests:GetHeight(iX, iY) >= self.iForestLevel) or (self.forestclumps:GetHeight(iX, iY) >= self.iClumpLevel) then


FractalWorld.lua

Gameplay/Lua/FractalWorld.lua
0680
local iHillsBottom1 = self.hillsFrac:GetHeight(hillsBottom1);
0693
local iMountain95 = self.mountainsFrac:GetHeight(95);
0717
local hillVal = self.hillsFrac:GetHeight(x, y);


Great_Plains.lua

Maps/Great_Plains.lua
0073
local iPlainsThreshold = hillsFrac:GetHeight(8);
0194
lat = lat + (128 - regionsFrac:GetHeight(x, y))/(255.0 * 5.0);
0374
local iTexDesertBottom = plains:GetHeight(iTexDesertBottomPercent)
0375
local iGrassTop = plains:GetHeight(iGrassTopPercent)
0376
local iGrassBottom = plains:GetHeight(iGrassBottomPercent)
0379
local iEastDTop = east:GetHeight(iEastDTopPercent)
0380
local iEastDBottom = east:GetHeight(iEastDBottomPercent)
0381
local iEastPTop = east:GetHeight(iEastPTopPercent)
0382
local iEastPBottom = east:GetHeight(iEastPBottomPercent)
0425
local val = east:GetHeight(x, y);
0497
local iRockyForestLevel = forests:GetHeight(iRockyForestPercent)
0499
local featureFloodPlains = FeatureTypes.FEATURE_FLOOD_PLAINS;
0541
if forests:GetHeight(x, y) <= iEastForestLevel then
1493
local iHerdsTop1 = herds:GetHeight(27)
1494
local iHerdsBottom2 = herds:GetHeight(73)


Hemispheres.lua (G&K)

DLC/Expansion/Maps/Hemispheres.lua
0822
local iHillsBottom1 = regionHillsFrac:GetHeight(20);
0823
local iHillsTop1 = regionHillsFrac:GetHeight(35);


Highlands.lua

Maps/Highlands.lua
0180
local iHillsThreshold = terrainFrac:GetHeight(hills);
0181
local iPeaksThreshold = terrainFrac:GetHeight(peaks);
0182
local iPassThreshold = mountain_passFrac:GetHeight(85);
0194
local passVal = mountain_passFrac:GetHeight(x,y);


MultilayeredFractal.lua (G&K)

DLC/Expansion/Gameplay/Lua/MultilayeredFractal.lua
0369
local iWaterThreshold = regionContinentsFrac:GetHeight(iWaterPercent);
0372
local iHillsBottom2 = regionHillsFrac:GetHeight(75 - adjustment);
0380
local val = regionContinentsFrac:GetHeight(x,y);


Ring.lua

Maps/Ring.lua
0511
self.iForestLevel   = self.forests:GetHeight(80) -- 20% forest coverage
0512
self.iClumpLevel   = self.forestclumps:GetHeight(94) -- 6% forest clumps
0513
self.iMarshLevel   = self.marsh:GetHeight(100 - self.fMarshPercent)
0515
if dominant_terrain == 3 then -- Forest
0517
self.iForestLevel   = self.forests:GetHeight(55) -- 45% forest coverage of what isn't covered by clumps.
0518
end


Skirmish.lua

Maps/Skirmish.lua
0307
elseif desertVal >= self.deserts:GetHeight(94) then


TerrainGenerator.lua

Gameplay/Lua/TerrainGenerator.lua
0113
self.iDesertBottom = self.deserts:GetHeight(self.iDesertBottomPercent);
0119
self.iPlainsTop = self.plains:GetHeight(self.iPlainsTopPercent);
0183
local plainsVal = self.plains:GetHeight(iX, iY);



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.