Trigger API Reference DCEI Functions General0 - funovus/editor-wiki 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 Actor(string actor)](#string-actorstring-actor)
* [string Unit(string unit)](#string-unitstring-unit)
* [string Effect(string effect)](#string-effectstring-effect)
* [string Behavior(string behavior)](#string-behaviorstring-behavior)
* [string Sound(string sound)](#string-soundstring-sound)
* [string Tag(string tag)](#string-tagstring-tag)
* [string Upgrade(string upgrade)](#string-upgradestring-upgrade)
* [string Font(string font)](#string-fontstring-font)
* [string Ability(string ability)](#string-abilitystring-ability)
* [void SetScreenSleep(bool flag)](#void-setscreensleepbool-flag)
* [float GetGameTime()](#float-getgametime)
* [object GetValueFromDataPath(String[] paths)](#object-getvaluefromdatapathstring-paths)
* [bool ValidateDataPath(String[] paths)](#bool-validatedatapathstring-paths)
* [void TriggerAddSimulationCommandEvent(int player, TypedCallback callback)](#void-triggeraddsimulationcommandeventint-player-typedcallbackstring-callback)
* [void SendSimulationCommand(string command)](#void-sendsimulationcommandstring-command)
* [void TriggerAddPresentationCommandEvent(TypedCallback callback)](#void-triggeraddpresentationcommandeventtypedcallbackstring-callback)
* [void SendPresentationCommand(int player, string command)](#void-sendpresentationcommandint-player-string-command)
* [void TriggerAddUpdateEvent(TypedCallback callback)](#void-triggeraddupdateeventtypedcallbackfloat-callback)
* [object CreateCustomIapProductData()](#object-createcustomiapproductdata)
* [object CreateCustomIapProduct(string productId, float price)](#object-createcustomiapproductstring-productid-float-price)
* [object AddCustomIapProduct(CustomIapProductData data, CustomIapProduct product)](#object-addcustomiapproductcustomiapproductdata-data-customiapproduct-product)
* [float GetProtectedValue(string key)](#float-getprotectedvaluestring-key)
* [void ClearProtectedValue(string key)](#void-clearprotectedvaluestring-key)
* [void SetProtectedValue(string key, float value)](#void-setprotectedvaluestring-key-float-value)
* [float ApplyModifier(BehaviorModifier modifier, float value)](#float-applymodifierbehaviormodifier-modifier-float-value)
* [bool IsPointOnNavMesh(float x, float z)](#bool-ispointonnavmeshfloat-x-float-z)
* [Float2 GetClosestPointOnNavMesh(float x, float z)](#float2-getclosestpointonnavmeshfloat-x-float-z)
* [void AddNavmeshCut(string prop_tag)](#void-addnavmeshcutstring-prop_tag)
* [void SetPropVisibility(string prop_tag, bool visibility)](#void-setpropvisibilitystring-prop_tag-bool-visibility)
|
Trigger API Reference\DCEI Functions\General (1/2) {Trigger-API-ReferenceDCEI-FunctionsGeneral-12}
string Texture(string texture)
DCEI.Texture("btn_close")
string Actor(string actor)
--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)
local unit_type = DCEI.Unit("Goblin")
DCEI.CreateUnit(1, 1, unit_type, 0, 1)
string Effect(string effect)
local effect = DCEI.Effect("EVENT Lightning Hook")
core.CreateEffect(effect, pos.x, pos.y)
string Behavior(string behavior)
local behavior = DCEI.Behavior("COMBAT Shield")
DCEI.ApplyBehaviorToSelf(target_unit, behavior, 1)
string Sound(string sound)
local sound = DCEI.Sound("dryad_bewitch_cast")
local volume = 2
DCEI.PlaySound(sound, volume)
string Tag(string tag)
local tag = DCEI.Tag("human")
DCEI.ApplyTag(unit, tag, -1, 5)
string Upgrade(string upgrade)
Register a used upgrade. This is mostly just used in Wild Sky.
local upgrade = DCEI.Upgrade("tech_tree_1")
DCEI.SetUpgradeLevelAsync(upgrade, 1)
string Font(string font)
string Ability(string ability)
local fireball_ability = DCEI.Ability("fireball")
DCEI.CastAbilityAtUnit(fireball_ability, caster_unit, target_unit, true)
void SetScreenSleep(bool flag)
If set to false, disable screen auto sleep; if set to true, use system screen sleep setting.
DCEI.SetScreenSleep(false)
float GetGameTime()
Returns the time passed since the game has started (in seconds).
DCEI.LogMessage(DCEI.GetGameTime())
object GetValueFromDataPath(String[] paths)
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.
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)
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.
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)
Call in logic script. Can get command from presentation script.
-
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.
--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)
Call in presentation script. Send command from presentation script to logic script.
--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)
Call in presentation script. Can get command from logic script.
-
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.
--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)
Call in logic script. Send command from logic script to presentation script.
-
int
player
player id of the triggering player -
string
command
the command sent to logic script, usually json encoded to contain more information
--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)
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.
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()
Returns a table for custom in-app product data.
local product_list = DCEI.CreateCustomIapProductData()
object CreateCustomIapProduct(string productId, float price) {object-CreateCustomIapProductstring-productId-float-price}
object CreateCustomIapProduct(string productId, float price)
Returns a custom in-app product with the values given.
DCEI.CreateCustomIapProduct("product_1", 1)
object AddCustomIapProduct(CustomIapProductData data, CustomIapProduct product) {object-AddCustomIapProductCustomIapProductData-data-CustomIapProduct-product}
object AddCustomIapProduct(CustomIapProductData data, CustomIapProduct product)
Combines the custom in app product data and product returned from the above functions and returns a whole product.
-
CustomIapProductData
data
data structure created from CreateCustomIapProductData(), -
CustomIapProduct
product
product structure created from CreateCustomIapProduct().
local product_list = DCEI.CreateCustomIapProductData()
local iap_item = DCEI.CreateCustomIapProduct("product_1", 1)
DCEI.AddCustomIapProduct(product_list, iap_item)
float GetProtectedValue(string key)
Returns a protected value from its key.
DCEI.SetProtectedValue("key", 1)
DCEI.LogMessage(DCEI.GetProtectedValue("key"))
void ClearProtectedValue(string key)
Clears the protected value pair of a given key.
DCEI.ClearProtectedValue("key")
void SetProtectedValue(string key, float value)
DCEI.SetProtectedValue("key", 1)
float ApplyModifier(BehaviorModifier modifier, float value) {float-ApplyModifierBehaviorModifier-modifier-float-value}
float ApplyModifier(BehaviorModifier modifier, float value)
Applies a behavior modifier to a value, returning the scaled/modified value.
-
BehaviorModifier
modifier
behavior modifier to apply. -
float
value
base value to scale by the BehaviorModifier.
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)
Returns true if the given coordinates are on the nav mesh.
DCEI.LogMessage(tostring(DCEI.IsPointOnNavMesh(16, 16)))
Float2 GetClosestPointOnNavMesh(float x, float z)
Returns the closest coordinates on the nav mesh to the given coordinates.
local point = DCEI.GetClosestPointOnNavMesh(-1, -1)
void AddNavmeshCut(string prop_tag)
Add a navmesh cut according to prop's tag, the navmesh cut will share the same position, rotation. and shape of this prop.
DCEI.AddNavmeshCut("prop_test")
void SetPropVisibility(string prop_tag, bool visibility) {void-SetPropVisibilitystring-prop_tag-bool-visibility}
void SetPropVisibility(string prop_tag, bool visibility)
Set the visibility of prop according to prop tag.
DCEI.SetPropVisibility("prop_test", false)