Trigger API Reference\DCEI Functions\Terrain

void EnableRoute(string routeName, bool enable)

void EnableRoute(string routeName, bool enable)

Description


Enable/disable a waypoints route according to route name.

Parameters

Example Usage

local routeName = "test_route"
DCEI.EnableRoute(routeName, true)

Float2 GetMapSize()

Float2 GetMapSize()

Description


Returns the X and Z dimensions of the map.

Example Usage

local map_dim = DCEI.GetMapSize()
DCEI.LogMessage("Map Dim X: " .. map_dim.x .. " Map Dim Z: " .. map_dim.y)

Float2 GetMapCenterPoint()

Float2 GetMapCenterPoint()

Description


Returns the X and Z coordinates of the center of the map.

Example Usage

local map_center = DCEI.GetMapCenterPoint()
DCEI.LogMessage("Map Center X: " .. map_center.x .. " Map Center Z: " .. map_center.y)

int GetTerrainTypeAtPoint(float x, float z)

int GetTerrainTypeAtPoint(float x, float z)

Description


Returns the terrain type at the given point. Returns 0-4 depending on the texture painted at the point, with 0 being the default texture. Ignores terrain features such as cliffs, borders, and water - this returns the texture that would otherwise be painted on the tile.

Parameters

Example Usage

local x, y = 16, 16
local terrain_type = DCEI.GetTerrainTypeAtPoint(x, y)
DCEI.LogMessage(terrain_type)

float GetTerrainHeightAtPoint(float x, float z)

float GetTerrainHeightAtPoint(float x, float z)

Description


Returns the terrain height at the given point. Values can range from 5 to -5. Default terrain height is 0, border height defaults to -1. Ignores water height.

Parameters

Example Usage

local x, y = 16, 16
local terrain_height = DCEI.GetTerrainHeightAtPoint(x, y)
DCEI.LogMessage(terrain_type)

void ChangePropLayerDisplay(string layerName, bool display)

void ChangePropLayerDisplay(string layerName, bool display)

Description


Enables or disables the display of a prop player.

Parameters

Example Usage

local button_layout = GMUI.Layout.New({
    parent = DCEI.GetUiRootFrame(),
    name = "Standard/Button/Button",
})

local layer_name = "layer_1"
DCEI.SetOnClickCallback(button_layout.Button, function()
    DCEI.ChangePropLayerDisplay(layer_name, false)
end)

void LoadPropLayer(string layerName, bool initialDisplay)

void LoadPropLayer(string layerName, bool initialDisplay)

Description


Loads the prop layer into memory. If prop layer has already been loaded, does nothing. Layers may need to be unloaded via UnloadPropLayer first.

Parameters

Example Usage

function OnRegionEnter()
    DCEI.LoadPropLayer("layer_1", true)
end

DCEI.UnloadPropLayer("layer_1")
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), DCEI.RegionAny, OnRegionEnter)


#### Related

void UnloadPropLayer(string layerName)

void UnloadPropLayer(string layerName)

Description


Unloads the given prop layer from memory, preventing it from being displayed. Prop layers unloaded can be reloaded via LoadPropLayer.

Parameters

Example Usage

function OnRegionEnter()
    DCEI.LoadPropLayer("layer_1", true)
end

DCEI.UnloadPropLayer("layer_1")
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), DCEI.RegionAny, OnRegionEnter)


#### Related

bool GetPropLayerLoadStatus(string layerName)

bool GetPropLayerLoadStatus(string layerName)

Description


Returns true if given prop layer is loaded.

Parameters

Example Usage

function OnRegionEnter()
    DCEI.LoadPropLayer("layer_1", true)
    DCEI.LogMessage(tostring(DCEI.GetPropLayerLoadStatus("layer_2")))
end

DCEI.UnloadPropLayer("layer_1")
DCEI.TriggerAddUnitEnterRegionEvent(DCEI.CreateUnitFilter({name = DCEI.Unit("Test Unit")}), DCEI.RegionAny, OnRegionEnter)


#### Related

Float3 GetTerrainChunkPosition(string chunkName)

Float3 GetTerrainChunkPosition(string chunkName)

Description


Returns the 3D position of a terrain chunk.

Parameters

Example Usage

local terrain_chunk_pos = DCEI.GetTerrainChunkPosition("terrain_chunk_0")
DCEI.LogMessage("X: " .. terrain_chunk_pos.x)
DCEI.LogMessage("Y: " .. terrain_chunk_pos.y)
DCEI.LogMessage("Z: " .. terrain_chunk_pos.z)

bool SetTerrainChunkPosition(string chunkName, Float3 pos)

bool SetTerrainChunkPosition(string chunkName, Float3 pos)

Description


Sets the position of a terrain chunk. Returns true if the terrain chunk position was set successfully.

Parameters

Example Usage

local new_pos = { x = 16, y = -3, z = 16 }
local move_success = DCEI.SetTerrainChunkPosition("terrain_chunk_0", new_pos)

if move_success then
    local terrain_chunk_pos = DCEI.GetTerrainChunkPosition("terrain_chunk_0")
    DCEI.LogMessage("X: " .. terrain_chunk_pos.x)
    DCEI.LogMessage("Y: " .. terrain_chunk_pos.y)
    DCEI.LogMessage("Z: " .. terrain_chunk_pos.z)
end

bool SetTerrainChunkPositionWithInterpolation(string chunkName, Float3 pos, float duration)

bool SetTerrainChunkPositionWithInterpolation(string chunkName, Float3 pos, float duration)

Description


Sets the 3D position of a terrain chunk while animating it to that position. Returns true if the position was set successfully.

Parameters

Example Usage

local new_pos = { x = 16, y = -3, z = 16 }
local duration = 5
local move_success = DCEI.SetTerrainChunkPositionWithInterpolation("terrain_chunk_0", new_pos, duration)

if move_success then
    local terrain_chunk_pos = DCEI.GetTerrainChunkPosition("terrain_chunk_0")
    DCEI.LogMessage("X: " .. terrain_chunk_pos.x)
    DCEI.LogMessage("Y: " .. terrain_chunk_pos.y)
    DCEI.LogMessage("Z: " .. terrain_chunk_pos.z)
end

int InstantiateTerrainChunk(string chunkName, Float3 pos)

int InstantiateTerrainChunk(string chunkName, Float3 pos)

Description


Instantiates a terrain chunk at the given location and returns the instanceId of the terrain chunk instance. Returns 0 on failure.

Parameters

Example Usage

local chunk_name = "terrain_chunk_0"
local pos = { x = 16, y = -3, z = 16 }
local chunk_id = DCEI.InstantiateTerrainChunk(chunk_name, pos)
DCEI.LogMessage("Terrain Chunk instance ID: " .. chunk_id)

void DestroyTerrainChunkInstance(int instanceId)

void DestroyTerrainChunkInstance(int instanceId)

Description


Destroys a terrain chunk instance.

Parameters

Example Usage

local button_layout = GMUI.Layout.New({
    parent = DCEI.GetUiRootFrame(),
    name = "Standard/Button/Button",
})

local chunk_id = 2
DCEI.SetOnClickCallback(button_layout.Button, function()
    DCEI.DestroyTerrainChunkInstance(chunk_id)
end)

Float3 GetTerrainChunkInstancePosition(int instanceId)

Float3 GetTerrainChunkInstancePosition(int instanceId)

Description


Returns the 3D position of a terrain chunk instance.

Parameters

Example Usage

local chunk_name = "terrain_chunk_0"
local pos = { x = 16, y = -3, z = 16 }
local chunk_id = DCEI.InstantiateTerrainChunk(chunk_name, pos)

local terrain_chunk_pos = DCEI.GetTerrainChunkInstancePosition(chunk_id)
DCEI.LogMessage("X: " .. terrain_chunk_pos.x)
DCEI.LogMessage("Y: " .. terrain_chunk_pos.y)
DCEI.LogMessage("Z: " .. terrain_chunk_pos.z)

bool SetTerrainChunkInstancePosition(int instanceId, Float3 pos)

bool SetTerrainChunkInstancePosition(int instanceId, Float3 pos)

Description


Sets the 3D position of a terrain chunk instance. Returns true if the position was set successfully.

Parameters

Example Usage

local chunk_name = "terrain_chunk_0"
local pos = { x = 16, y = -3, z = 16 }
local chunk_id = DCEI.InstantiateTerrainChunk(chunk_name, pos)

local new_pos = { x = 20, y = -3, z = 20 }
local move_success = DCEI.SetTerrainChunkInstancePositionWithInterpolation(chunk_id, new_pos)

if move_success then
    DCEI.LogMessage("Success!")
end

bool SetTerrainChunkInstancePositionWithInterpolation(int instanceId, Float3 pos, float duration)

bool SetTerrainChunkInstancePositionWithInterpolation(int instanceId, Float3 pos, float duration)

Description


Sets the 3D position of a terrain chunk instance while animating it to that position. Returns true if the position was set successfully.

Parameters

Example Usage

local chunk_name = "terrain_chunk_0"
local pos = { x = 16, y = -3, z = 16 }
local chunk_id = DCEI.InstantiateTerrainChunk(chunk_name, pos)

local new_pos = { x = 20, y = -3, z = 20 }
local duration = 5
local move_success = DCEI.SetTerrainChunkInstancePositionWithInterpolation(chunk_id, new_pos, duration)

if move_success then
    DCEI.LogMessage("Success!")
end

int GetWeather()

int GetWeather()

Description


Returns an integer corresponding to the weather. Does not detect the heatwave option.
0 - None
1 - Rain
2 - Snow

Example Usage

local weather = DCEI.GetWeather()
DCEI.LogMessage(weather)

void SetWeather(int weatherStatus, float duration = 4)

void SetWeather(int weatherStatus, float duration = 4)

Description


Changes the weather over the given duration. Use 0 for an instant transition. Cannot set the heatwave option.
In order to use a weather, you'll need to set Has Weather Name in the weather settings. To find it, go to Project Settings > Map Settings > Weather. Make sure you're in the settings for your map, not a mod that the map is using.

0 - None
1 - Rain
2 - Snow

Parameters

Example Usage

local new_weather = 2
local duration = 50
DCEI.SetWeather(new_weather, duration)

local weather = DCEI.GetWeather()
DCEI.LogMessage(weather)

int GetTimeOfTheDay()

int GetTimeOfTheDay()

Description


Returns an integer corresponding to the time of the day.
0 - Noon
1 - Night
2 - Void

Example Usage

local new_time = 1
local duration = 5
DCEI.SetTimeOfTheDay(new_time, duration)

local time = DCEI.GetTimeOfTheDay()
DCEI.LogMessage(time)

void SetTimeOfTheDay(int timeOfTheDay, float duration = 4)

void SetTimeOfTheDay(int timeOfTheDay, float duration = 4)

Description


Sets a time of the day over the given duration. Use 0 for an instant transition.
0 - Noon
1 - Night
2 - Void

Parameters

Example Usage

local new_time = 1
local duration = 5
DCEI.SetTimeOfTheDay(new_time, duration)

local time = DCEI.GetTimeOfTheDay()
DCEI.LogMessage(time)

ColorRGB GetCurrentLightColor()

ColorRGB GetCurrentLightColor()

Description


Get the current light's RGB value

Example Usage

local light_color = DCEI.GetCurrentLightColor()
DCEI.LogMessage("R: " .. light_color.r)
DCEI.LogMessage("G: " .. light_color.g)
DCEI.LogMessage("B: " .. light_color.b)

void SetOverrideLightColor(ColorRGB color, float duration)

void SetOverrideLightColor(ColorRGB color, float duration)

Description


Set light color RGB value for a period of time

Parameters

Example Usage

local new_color = { r = 0.1, g = 0.1, b = 0.9 }
local duration = 3
DCEI.SetOverrideLightColor(new_color, duration)

void SetSkyboxColor(ColorRGB color, float duration)

void SetSkyboxColor(ColorRGB color, float duration)

Description


Set skybox RGB color value for a period of time.

Parameters

Example Usage

-- Sets the skybox to a new color over 3 seconds
local new_color = { r = 1, g = 0.1, b = 0.5 }
local duration = 3
DCEI.SetSkyboxColor(new_color, duration)

-- Resets it after 5 seconds
local reset_timer = 5
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.ResetSkyboxColor(0)
end, reset_timer)

void ResetSkyboxColor(float duration)

void ResetSkyboxColor(float duration)

Description


Resets the skybox color to the default over the given duration. Use 0 for an instant transition.

Parameters

Example Usage

-- Sets the skybox to a new color over 3 seconds
local new_color = { r = 1, g = 0.1, b = 0.5 }
local duration = 3
DCEI.SetSkyboxColor(new_color, duration)

-- Resets it after 5 seconds
local reset_timer = 5
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.ResetSkyboxColor(0)
end, reset_timer)

int AddLine(Float3 startPos, Float3 endPos, float width, ColorRGBA color, bool rectCap = False)

int AddLine(Float3 startPos, Float3 endPos, float width, ColorRGBA color, bool rectCap = False)

Description


Draws a line on the terrain, with color! Returns the lineId of the created line if successful.

Parameters

Example Usage

-- Creates a line
local start_pos = { x = 10, y = 1, z = 15 }
local end_pos = { x = 20, y = 1, z = 15 }
local width = 1
local color = { r = 1, g = 0.5, b = 0.5, a = 0.5 }
local rect_cap = true
local line_id = DCEI.AddLine(start_pos, end_pos, width, color, rect_cap)

-- Removes it after 2 seconds
local line_duration = 2
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.RemoveLine(line_id)
end, line_duration)

int AddLineWithSprite(Float3 startPos, Float3 endPos, float width, ColorRGBA color, string spriteName, float tex_multiplier = 1)

int AddLineWithSprite(Float3 startPos, Float3 endPos, float width, ColorRGBA color, string spriteName, float tex_multiplier = 1)

Description


Draws a line on the terrain using repeating sprites. Returns the lineId of the created line if successful.

Parameters

Example Usage

-- Creates a line
local start_pos = { x = 10, y = 1, z = 15 }
local end_pos = { x = 20, y = 1, z = 15 }
local width = 1
local color = { r = 1, g = 0.5, b = 0.5, a = 0.5 }
local line_sprite = DCEI.Texture("airship_onMap")
local tex_multiplier = 1
local line_id = DCEI.AddLineWithSprite(start_pos, end_pos, width, color, line_sprite, tex_multiplier)

-- Removes it after 2 seconds
local line_duration = 2
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.RemoveLine(line_id)
end, line_duration)

void RemoveLine(int lineId)

void RemoveLine(int lineId)

Description


Removes a line.

Parameters

Example Usage

-- Creates a line
local start_pos = { x = 10, y = 1, z = 15 }
local end_pos = { x = 20, y = 1, z = 15 }
local width = 1
local color = { r = 1, g = 0.5, b = 0.5, a = 0.5 }
local rect_cap = true
local line_id = DCEI.AddLine(start_pos, end_pos, width, color, rect_cap)

-- Removes it after 2 seconds
local line_duration = 2
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.RemoveLine(line_id)
end, line_duration)

void MoveLineWithInterpolation(int lineId, Float3 startPos, Float3 endPos, float duration)

void MoveLineWithInterpolation(int lineId, Float3 startPos, Float3 endPos, float duration)

Description


Moves a line's start and end points (and thus the line itself) to new locations over the given duration.

Parameters

Example Usage

-- Creates a line
local start_pos = { x = 10, y = 1, z = 15 }
local end_pos = { x = 20, y = 1, z = 15 }
local width = 1
local color = { r = 1, g = 0.5, b = 0.5, a = 0.5 }
local rect_cap = true
local line_id = DCEI.AddLine(start_pos, end_pos, width, color, rect_cap)

-- Moves it
local new_start_pos = { x = 15, y = 1, z = 15 }
local new_end_pos = { x = 15, y = 1, z = 20 }
local move_duration = 3
DCEI.MoveLineWithInterpolation(line_id, new_start_pos, new_end_pos, move_duration)

void RemoveAllLines()

void RemoveAllLines()

Description


Removes all lines.

Example Usage

-- Creates a group of lines
for i = 1, 10, 1 do
    local start_pos = { x = 10 + i, y = 1, z = 15 }
    local end_pos = { x = 10 + i, y = 1, z = 20 }
    local width = 0.5
    local color = { r = 1, g = 0.5, b = 0.5, a = 0.5 }
    local rect_cap = true
    DCEI.AddLine(start_pos, end_pos, width, color, rect_cap)
end

-- Removes them after 2 seconds
local line_duration = 2
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.RemoveAllLines()
end, line_duration)

void ChangeLineColor(int lineId, ColorRGBA color)

void ChangeLineColor(int lineId, ColorRGBA color)

Description


Changes a line's color.

Parameters

Example Usage

-- Creates a line
local start_pos = { x = 10, y = 1, z = 15 }
local end_pos = { x = 20, y = 1, z = 15 }
local width = 1
local color = { r = 1, g = 0.5, b = 0.5, a = 0.5 }
local rect_cap = true
local line_id = DCEI.AddLine(start_pos, end_pos, width, color, rect_cap)

-- Changes color after 2 seconds
local line_duration = 2
DCEI.TriggerAddTimerEventElapsed(function()
    local new_color = { r = 0.1, g = 0.1, b = 0.75, a = 0.75 }
    DCEI.ChangeLineColor(line_id, new_color)
end, line_duration)

void ChangeLineDisplay(int lineId, bool display)

void ChangeLineDisplay(int lineId, bool display)

Description


Toggles the display of a line.

Parameters

Example Usage

-- Creates a line
local start_pos = { x = 10, y = 1, z = 15 }
local end_pos = { x = 20, y = 1, z = 15 }
local width = 1
local color = { r = 1, g = 0.5, b = 0.5, a = 0.5 }
local rect_cap = true
local line_id = DCEI.AddLine(start_pos, end_pos, width, color, rect_cap)

-- Hides it after 2 seconds
local line_duration = 2
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.ChangeLineDisplay(line_id, false)
end, line_duration)

int AddGrid(Float3 center, float width, float height, int xCount, int zCount, float lineWidth, ColorRGBA color, bool rectCap = False)

int AddGrid(Float3 center, float width, float height, int xCount, int zCount, float lineWidth, ColorRGBA color, bool rectCap = False)

Description


Draws a grid with lines. Returns a gridId integer if successful.

Parameters

Example Usage

-- Creates a grid
local center = { x = 16, y = 1, z = 16 }
local width = 5.5
local height = 5.5
local xCount = 5
local zCount = 6
local line_width = 0.1
local color = { r = 1, g = 0.5, b = 0.5, a = 0.5 }
local rect_cap = false
local grid_id = DCEI.AddGrid(center, width, height, xCount, zCount, line_width, color, rect_cap)

-- Removes it after 2 seconds
local line_duration = 2
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.RemoveGrid(grid_id)
end, line_duration)

int AddGridWithSprite(Float3 center, float width, float height, int xCount, int zCount, float lineWidth, ColorRGBA color, string spriteName, float tex_multiplier = 1)

int AddGridWithSprite(Float3 center, float width, float height, int xCount, int zCount, float lineWidth, ColorRGBA color, string spriteName, float tex_multiplier = 1)

Description


Draws a grid with lines made of repeating sprites. Returns a gridId integer if successful.

Parameters

Example Usage

-- Creates a grid
local center = { x = 16, y = 1, z = 16 }
local width = 10.5
local height = 10.5
local xCount = 5
local zCount = 6
local line_width = 0.5
local color = { r = 1, g = 0.5, b = 0.5, a = 0.5 }
local sprite = DCEI.Texture("airship_onMap")
local tex_multiplier = 1
local grid_id = DCEI.AddGridWithSprite(center, width, height, xCount, zCount, line_width, color, sprite, tex_multiplier)

-- Removes it after 2 seconds
local line_duration = 2
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.RemoveGrid(grid_id)
end, line_duration)

void RemoveGrid(int gridId)

void RemoveGrid(int gridId)

Description


Removes a grid.

Parameters

Example Usage

-- Creates a grid
local center = { x = 16, y = 1, z = 16 }
local width = 5.5
local height = 5.5
local xCount = 5
local zCount = 6
local line_width = 0.1
local color = { r = 1, g = 0.5, b = 0.5, a = 0.5 }
local rect_cap = false
local grid_id = DCEI.AddGrid(center, width, height, xCount, zCount, line_width, color, rect_cap)

-- Removes it after 2 seconds
local line_duration = 2
DCEI.TriggerAddTimerEventElapsed(function()
    DCEI.RemoveGrid(grid_id)
end, line_duration)

void SetBlurredScreenCaptureAsBackground(bool set, float duration)

void SetBlurredScreenCaptureAsBackground(bool set, float duration)

Description


Toggles a blurred version of your terrain in the background. Note that this background renders underneath the terrain, so you may need to move your game camera to see it.

Parameters

Example Usage

-- Creates a button
local button_layout = GMUI.Layout.New({
    parent = DCEI.GetUiRootFrame(),
    name = "Standard/Button/Button",
})

-- Sets the current screen as the background over 1 second when the button is pressed
DCEI.SetOnClickCallback(button_layout.Button, function()
    DCEI.SetBlurredScreenCaptureAsBackground(true, 1)

    -- Removes it after 2 seconds
    local reset_duration = 2
    DCEI.TriggerAddTimerEventElapsed(function()
        DCEI.SetBlurredScreenCaptureAsBackground(false, 0)
    end, reset_duration)
end)