Trigger API Reference DCEI Functions General0 - BLKTower/TestWiki GitHub Wiki

Table of Contents

Trigger API Reference\DCEI Functions\General (1/2) {Trigger-API-ReferenceDCEI-FunctionsGeneral-12}

string Texture(string texture) {string-Texturestring-texture}

string Texture(string texture)

Description

Register a used sprite.

Parameters

  • string texture the sprite name to register.

Example Usage

DCEI.Texture("btn_close")

string Actor(string actor) {string-Actorstring-actor}

string Actor(string actor)

Description

Register a used actor.

Parameters

  • string actor the actor name to register.

Example Usage

--this creates an vfx model actor on your unit
on_hit = DCEI.Actor("COMBAT AreaAttack Impact FX")
core.SendActorMessage(target_unit, "create", on_hit)

string Unit(string unit) {string-Unitstring-unit}

string Unit(string unit)

Description

Register a used unit.

Parameters

  • string unit the unit name to register.

Example Usage

local unit_type = DCEI.Unit("Goblin")
DCEI.CreateUnit(1, 1, unit_type, 0, 1)

string Effect(string effect) {string-Effectstring-effect}

string Effect(string effect)

Description

Register a used effect.

Parameters

  • string effect the effect name to register.

Example Usage

local effect = DCEI.Effect("EVENT Lightning Hook")
core.CreateEffect(effect, pos.x, pos.y)

string Behavior(string behavior) {string-Behaviorstring-behavior}

string Behavior(string behavior)

Description

Register a used behavior.

Parameters

  • string behavior the actor name to register.

Example Usage

local behavior = DCEI.Behavior("COMBAT Shield")
DCEI.ApplyBehaviorToSelf(target_unit, behavior, 1)

string Sound(string sound) {string-Soundstring-sound}

string Sound(string sound)

Description

Register a used sound.

Parameters

  • string sound the sound name to register.

Example Usage

local sound = DCEI.Sound("dryad_bewitch_cast")
local volume = 2
DCEI.PlaySound(sound, volume)

string Tag(string tag) {string-Tagstring-tag}

string Tag(string tag)

Description

Register a used tag.

Parameters

  • string tag the tag name to register.

Example Usage

local tag = DCEI.Tag("human")
DCEI.ApplyTag(unit, tag, -1, 5)

string Upgrade(string upgrade) {string-Upgradestring-upgrade}

string Upgrade(string upgrade)

Description

Register a used upgrade. This is mostly just used in Wild Sky.

Parameters

  • string upgrade the upgrade name to register.

Example Usage

local upgrade = DCEI.Upgrade("tech_tree_1")
DCEI.SetUpgradeLevelAsync(upgrade, 1)

string Font(string font) {string-Fontstring-font}

string Font(string font)

Description

Register a used font.

Parameters

  • string font the font name to register.

Example Usage

string Ability(string ability) {string-Abilitystring-ability}

string Ability(string ability)

Description

Register a used ability.

Parameters

  • string ability the ability name to register.

Example Usage

local fireball_ability = DCEI.Ability("fireball")
DCEI.CastAbilityAtUnit(fireball_ability, caster_unit, target_unit, true)

void SetScreenSleep(bool flag) {void-SetScreenSleepbool-flag}

void SetScreenSleep(bool flag)

Description

If set to false, disable screen auto sleep; if set to true, use system screen sleep setting.

Parameters

  • bool flag the screen sleep state to set.

Example Usage

DCEI.SetScreenSleep(false)

float GetGameTime() {float-GetGameTime}

float GetGameTime()

Description

Returns the time passed since the game has started (in seconds).

Example Usage

DCEI.LogMessage(DCEI.GetGameTime())

object GetValueFromDataPath(String[] paths) {object-GetValueFromDataPathString-paths}

object GetValueFromDataPath(String[] paths)

Description

Returns the value stored at the given data path. This can only return either a string or integer. You can find a data object's json path names in the JSON view of data editor and use them directly with the API. You can also right click any field in the editor and select "Copy Data Path" to copy the field's data path to the clipboard.

Parameters

  • String[] paths the paths to retrieve values from. Accepts both lowerCamelCase and snake_case.

Example Usage

local data_path = {"units", "Standard MeleeUnit", "components", "unitStats", "radius"}
if DCEI.ValidateDataPath(data_path) then
    local data_path_val = DCEI.GetValueFromDataPath(data_path)
    DCEI.LogMessage(data_path_val)
end

bool ValidateDataPath(String[] paths) {bool-ValidateDataPathString-paths}

bool ValidateDataPath(String[] paths)

Description

Returns true if value stored at the given data path is a string or integer. You can find a data object's json path names in the JSON view of data editor and use them directly with the API. You can also right click any field in the editor and select "Copy Data Path" to copy the field's data path to the clipboard.

Parameters

  • String[] paths the paths to validate. Accepts both lowerCamelCase and snake_case.

Example Usage

local data_path = {"units", "Standard MeleeUnit", "components", "unit_stats", "radius"}
if DCEI.ValidateDataPath(data_path) then
    local data_path_val = DCEI.GetValueFromDataPath(data_path)
    DCEI.LogMessage(data_path_val)
end

void TriggerAddSimulationCommandEvent(int player, TypedCallback<string> callback) {void-TriggerAddSimulationCommandEventint-player-TypedCallbackstring-callback}

void TriggerAddSimulationCommandEvent(int player, TypedCallback<string> callback)

Description

Call in logic script. Can get command from presentation script.

Parameters

  • int player player id of the triggering player
  • object callback the callback function that is run when the event is triggered. the string parameter is the command sent from presentation scrip, usually json encoded for more info.

Example Usage

--this runs in logic script, receiving command from presentation scrip
DCEI.TriggerAddSimulationCommandEvent(
  1,
  function(payload)
    local command = json.decode(payload)
    if command.type == "set_speed" then
      speed = command.speed
      DCEI.LogMessage("Speed change to: " .. speed)
    elseif command.type == "pause_unpause" then
      pause = not pause
    end
  end
)
-- Put this in presentation script, when the button is clicked, send command to logic script
DCEI.SetOnClickCallback(
  window,
  function()
    DCEI.SendSimulationCommand(
      json.encode(
        {
          type = "pause_unpause"
        }
      )
    )
  end
)

void SendSimulationCommand(string command) {void-SendSimulationCommandstring-command}

void SendSimulationCommand(string command)

Description

Call in presentation script. Send command from presentation script to logic script.

Parameters

  • string command the command sent to logic script, usually json encoded to contain more information

Example Usage

--this runs in logic script, receiving command from presentation scrip
DCEI.TriggerAddSimulationCommandEvent(
  1,
  function(payload)
    local command = json.decode(payload)
    if command.type == "set_speed" then
      speed = command.speed
      DCEI.LogMessage("Speed change to: " .. speed)
    elseif command.type == "pause_unpause" then
      pause = not pause
    end
  end
)
-- Put this in presentation script, when the button is clicked, send command to logic script
DCEI.SetOnClickCallback(
  window,
  function()
    DCEI.SendSimulationCommand(
      json.encode(
        {
          type = "pause_unpause"
        }
      )
    )
  end
)

void TriggerAddPresentationCommandEvent(TypedCallback<string> callback) {void-TriggerAddPresentationCommandEventTypedCallbackstring-callback}

void TriggerAddPresentationCommandEvent(TypedCallback<string> callback)

Description

Call in presentation script. Can get command from logic script.

Parameters

  • object callback the callback function that is run when the event is triggered. the string parameter is the command sent to presentation scrip, usually json encoded for more info.

Example Usage

--this runs in presentation script, receiving command from logic scrip
DCEI.TriggerAddPresentationCommandEvent(function(payload)
    local command = json.decode(payload)
    if command.type == "pause_unpause" then
        pause = not pause
    end
end)
-- Put this in logic script, when the button is clicked, send command to presentation script
DCEI.SetOnClickCallback(
  window,
  function()
    DCEI.SendPresentationCommand(
      1,
      json.encode(
        {
          type = "pause_unpause"
        }
      )
    )
  end
)

void SendPresentationCommand(int player, string command) {void-SendPresentationCommandint-player-string-command}

void SendPresentationCommand(int player, string command)

Description

Call in logic script. Send command from logic script to presentation script.

Parameters

  • int player player id of the triggering player
  • string command the command sent to logic script, usually json encoded to contain more information

Example Usage

--this runs in presentation script, receiving command from logic scrip
DCEI.TriggerAddPresentationCommandEvent(function(payload)
    local command = json.decode(payload)
    if command.type == "pause_unpause" then
        pause = not pause
    end
end)
-- Put this in logic script, when the button is clicked, send command to presentation script
DCEI.SetOnClickCallback(
  window,
  function()
    DCEI.SendPresentationCommand(
      1,
      json.encode(
        {
          type = "pause_unpause"
        }
      )
    )
  end
)

void TriggerAddUpdateEvent(TypedCallback<float> callback) {void-TriggerAddUpdateEventTypedCallbackfloat-callback}

void TriggerAddUpdateEvent(TypedCallback<float> callback)

Description

Run the callback function every presentation frame, which is way higher than logic frame (16 fps fixed for now). This can be used to create smooth UI animations.

Parameters

  • object callback the callback function that is run every presentation frame.

Example Usage

local rotation = 0
DCEI.TriggerAddUpdateEvent(
    function(delta_time)
        if not pause then
            rotation = rotation + speed * 90 * delta_time
            DCEI.SetRotation(window, rotation)
        end
    end
)

object CreateCustomIapProductData() {object-CreateCustomIapProductData}

object CreateCustomIapProductData()

Description

Returns a table for custom in-app product data.

Example Usage

local product_list = DCEI.CreateCustomIapProductData()

object CreateCustomIapProduct(string productId, float price) {object-CreateCustomIapProductstring-productId-float-price}

object CreateCustomIapProduct(string productId, float price)

Description

Returns a custom in-app product with the values given.

Parameters

  • string productId the product ID.
  • float price the price for the product.

Example Usage

DCEI.CreateCustomIapProduct("product_1", 1)

object AddCustomIapProduct(CustomIapProductData data, CustomIapProduct product) {object-AddCustomIapProductCustomIapProductData-data-CustomIapProduct-product}

object AddCustomIapProduct(CustomIapProductData data, CustomIapProduct product)

Description

Combines the custom in app product data and product returned from the above functions and returns a whole product.

Parameters

  • CustomIapProductData data data structure created from CreateCustomIapProductData(),
  • CustomIapProduct product product structure created from CreateCustomIapProduct().

Example Usage

local product_list = DCEI.CreateCustomIapProductData()
local iap_item = DCEI.CreateCustomIapProduct("product_1", 1)
DCEI.AddCustomIapProduct(product_list, iap_item)

float GetProtectedValue(string key) {float-GetProtectedValuestring-key}

float GetProtectedValue(string key)

Description

Returns a protected value from its key.

Parameters

  • string key key associated with the value.

Example Usage

DCEI.SetProtectedValue("key", 1)
DCEI.LogMessage(DCEI.GetProtectedValue("key"))

void ClearProtectedValue(string key) {void-ClearProtectedValuestring-key}

void ClearProtectedValue(string key)

Description

Clears the protected value pair of a given key.

Parameters

  • string key the key to clear.

Example Usage

DCEI.ClearProtectedValue("key")

void SetProtectedValue(string key, float value) {void-SetProtectedValuestring-key-float-value}

void SetProtectedValue(string key, float value)

Description

Sets a protected value pair.

Parameters

  • string key the key of the pair.
  • float value the value of the pair.

Example Usage

DCEI.SetProtectedValue("key", 1)

float ApplyModifier(BehaviorModifier modifier, float value) {float-ApplyModifierBehaviorModifier-modifier-float-value}

float ApplyModifier(BehaviorModifier modifier, float value)

Description

Applies a behavior modifier to a value, returning the scaled/modified value.

Parameters

  • BehaviorModifier modifier behavior modifier to apply.
  • float value base value to scale by the BehaviorModifier.

Example Usage

DCEI.LogMessage(DCEI.ApplyModifier({scaled = 5, unscaled = 0, additive_factor = 1, positive_unified_factor = 1, negative_unified_factor = 0, multiplier_factor = 1}, 5))

bool IsPointOnNavMesh(float x, float z) {bool-IsPointOnNavMeshfloat-x-float-z}

bool IsPointOnNavMesh(float x, float z)

Description

Returns true if the given coordinates are on the nav mesh.

Parameters

  • float x the x coordinate.
  • float z the z coordinate.

Example Usage

DCEI.LogMessage(tostring(DCEI.IsPointOnNavMesh(16, 16)))

Float2 GetClosestPointOnNavMesh(float x, float z) {Float2-GetClosestPointOnNavMeshfloat-x-float-z}

Float2 GetClosestPointOnNavMesh(float x, float z)

Description

Returns the closest coordinates on the nav mesh to the given coordinates.

Parameters

  • float x the x coordinate.
  • float z the z coordinate.

Example Usage

local point = DCEI.GetClosestPointOnNavMesh(-1, -1)

void AddNavmeshCut(string prop_tag) {void-AddNavmeshCutstring-prop_tag}

void AddNavmeshCut(string prop_tag)

Description

Add a navmesh cut according to prop's tag, the navmesh cut will share the same position, rotation. and shape of this prop.

Parameters

  • string prop_tag the prop's tag.

Example Usage

DCEI.AddNavmeshCut("prop_test")

void SetPropVisibility(string prop_tag, bool visibility) {void-SetPropVisibilitystring-prop_tag-bool-visibility}

void SetPropVisibility(string prop_tag, bool visibility)

Description

Set the visibility of prop according to prop tag.

Parameters

  • string prop_tag the prop's tag.
  • bool visibility if true, make the prop visible.

Example Usage

DCEI.SetPropVisibility("prop_test", false)

⚠️ **GitHub.com Fallback** ⚠️