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

Table of Contents

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

string GetTranslationText(string key, Dictionary<string, object> parameters) {string-GetTranslationTextstring-key-Dictionarystring-object-parameters}

string GetTranslationText(string key, Dictionary<string, object> parameters)

Description

Returns a localized string from localization data using the specified key. Additional parameters can be used for replacement text.

You can change what language is used in the editor in Play Settings.

Parameters

  • string key the localization key to use.
  • Dictionary parameters (optional) a table of replacement text keys.

Example Usage

-- key: "data/hero/ice_mage/skill01/description"
-- english text: "Slows nearby enemies by {[x]} for {[y]} seconds."
-- logged text: "Slows nearby enemies by 50% for 3 seconds."

local text = DCEI.GetTranslationText("data/hero/ice_mage/skill01/description", { x = "50%", y = "3" })
DCEI.LogMessage(text)

bool IsAdsReady() {bool-IsAdsReady}

bool IsAdsReady()

Description

Returns true if ads are ready.

Example Usage

local ads_ready = DCEI.IsAdsReady()
if ads_ready then
    DCEI.ShowAds(ResolveAds)
end

void ShowAds(TypedCallback<bool> callback, bool fallbackToUnityAds) {void-ShowAdsTypedCallbackbool-callback-bool-fallbackToUnityAds}

void ShowAds(TypedCallback<bool> callback, bool fallbackToUnityAds)

Description

Attempts to show ads in published mobile and web games. If successful, the first parameter of the callback function will return true. This can be simulated in Play Settings.

Parameters

  • object callback this callback function is called once ShowAds() has resolved. If watching ads was successful, the first parameter of this callback function will return true.
  • bool fallbackToUnityAds if true, uses unity ads as a fallback.

Example Usage

function ResolveAds(success)
  if success then
    -- deliver ad rewards to player
  else
    -- show error message for player
  end
end

DCEI.ShowAds(ResolveAds)

bool IsOnline() {bool-IsOnline}

bool IsOnline()

Description

Returns true if the user currently has internet access. This can be simulated in Play Settings.

Example Usage

local is_online = DCEI.IsOnline()
if is_online then
    DCEI.LogMessage(tostring(is_online))
end

bool IsDev() {bool-IsDev}

bool IsDev()

Description

Returns true if the user currently has developer access. This can be simulated in Play Settings.

Example Usage

local is_dev = DCEI.IsDev()
if is_dev then
    DCEI.LogMessage(tostring(is_dev))
end

void ShowSettings() {void-ShowSettings}

void ShowSettings()

Description

Show the game settings menu. Only works on mobile.

Example Usage

DCEI.ShowSettings()

void GetSaveDataHistory(int count, TypedCallback<object> callback) {void-GetSaveDataHistoryint-count-TypedCallbackobject-callback}

void GetSaveDataHistory(int count, TypedCallback<object> callback)

Description

Attempts to fetch the player's save history. If successful, the callback will return with the save history as a table as its first parameter.

Parameters

  • int count the number of save data instances to include in the callback table, with the most recent saves returned first. Max 10.
  • object callback the callback function to handle the returned save data instances.

Example Usage

local function ResultCallback(result)
    if result then
        for _, save in ipairs(result.saves) do
            DCEI.LogMessage("Save data timestamp:" .. save.time)
        end       
    end
end
DCEI.GetSaveDataHistory(count, ResultCallback)

void ResetSavedMapDataByIndex(int index) {void-ResetSavedMapDataByIndexint-index}

void ResetSavedMapDataByIndex(int index)

Description

Attempts to resets the saved map data at the given index.

Parameters

  • int index the saved map data index to reset.

Example Usage

DCEI.ResetSavedMapDataByIndex(1)

void GetMail(TypedCallback<object> callback, bool forceFetch) {void-GetMailTypedCallbackobject-callback-bool-forceFetch}

void GetMail(TypedCallback<object> callback, bool forceFetch)

Description

Attempts to fetch the player's mail. If successful, the callback will return with the save history as a table as its first parameter.

Parameters

  • object callback the callback function to handle the returned mail.
  • bool forceFetch if true, forces a fetch.

Example Usage

function MailHandler(result)
    --Handle mail
end
DCEI.GetMail(MailHandler, false)

void DeleteMail(int instanceId) {void-DeleteMailint-instanceId}

void DeleteMail(int instanceId)

Description

Attempts to delete the mail with the given ID.

Parameters

  • int instanceId the ID of the mail to delete.

Example Usage

DCEI.DeleteMail(1)

int ScheduleNotification(string title, string body, double timeInSeconds) {int-ScheduleNotificationstring-title-string-body-double-timeInSeconds}

int ScheduleNotification(string title, string body, double timeInSeconds)

Description

Schedules a notification and returns the ID of said notification. Only works on mobile.

Parameters

  • string title the title of the notification.
  • string body the body text of the notification.
  • double timeInSeconds the duration to wait before triggering the notification.

Example Usage

DCEI.ScheduleNotification("Title", "Notification", 120)

void CancelNotification(int id) {void-CancelNotificationint-id}

void CancelNotification(int id)

Description

Cancels a notification from the given id. Only works on mobile.

Parameters

  • int id the ID of the notification to cancel.

Example Usage

DCEI.CancelNotification(1)

object GetLastNotificationId() {object-GetLastNotificationId}

object GetLastNotificationId()

Description

Returns the last notification ID. Only works on mobile.

Example Usage

local last_notif_id = DCEI.GetLastNotificationId()

void ShowSendSMS(int platform) {void-ShowSendSMSint-platform}

void ShowSendSMS(int platform)

Description

Shows the SMS invitation screen. Only works on mobile or web builds.

Parameters

  • int platform the platform used to send the SMS. Use 1 for Android and 2 for iOS.

Example Usage

DCEI.ShowSendSMS(1)

void RestartApplication() {void-RestartApplication}

void RestartApplication()

Description

Restarts the application. Only works on mobile.

Example Usage

DCEI.RestartApplication()

void OpenUrl(string url) {void-OpenUrlstring-url}

void OpenUrl(string url)

Description

Opens a web url in the user's default browser.

Parameters

  • string url the url to open.

Example Usage

DCEI.OpenUrl("http://localhost:7777/Wiki/TestBranch/Trigger-API-Reference-DCEI-Functions-Service0#openurl")

void RequestAppStoreReview() {void-RequestAppStoreReview}

void RequestAppStoreReview()

Description

Requests an app store review. Only works on iOS devices.

Example Usage

DCEI.RequestAppStoreReview()

void RequestInAppReview(Action successCallback, Action failureCallback) {void-RequestInAppReviewAction-successCallback-Action-failureCallback}

void RequestInAppReview(Action successCallback, Action failureCallback)

Description

Requests an in-app review. Only works on iOS devices.

Parameters

  • Action successCallback the action that is taken on a successful review.
  • Action failureCallback the action that is taken on a failed review.

Example Usage

DCEI.RequestInAppReview(SuccessCallback, FailureCallback)

void GetServerTime(TypedCallback<int> callback) {void-GetServerTimeTypedCallbackint-callback}

void GetServerTime(TypedCallback<int> callback)

Description

Attempts to return the server time as the first parameter of a callback function.

Parameters

  • object callback the callback function that handles the server time.

Example Usage

local function ResultCallback( time_stamp )
  if time_stamp then
    -- retrieving server time was successful and time_stamp will be the current unix timestamp
  else
    -- connection failed/timeout
  end
end

DCEI.GetServerTime( ResultCallback )

Note that in editor mode, DCEI.GetServerTime() will always return the local os time, using a delay to simulate network latency.

In production, time_stamp can fail or take some time to return and you must account for these cases (player has no internet or is in airplane mode, most games display a "cannot connect to server" message when an offline player tries to do something that requires internet).

Ideally you only need to successfully call DCEI.GetServerTime() once (or once per day).

Say if a daily rewards calendar resets at midnight PST, that you only need to check again after midnight. For other things just use os time or keep track of in-game time.

string GetUserId() {string-GetUserId}

string GetUserId()

Description

Returns the player's internal user ID. This can be simulated in Play Settings.

Example Usage

local user_id = DCEI.GetUserId()
DCEI.LogMessage(user_id)

string GetUserName() {string-GetUserName}

string GetUserName()

Description

Returns the player's username.

Example Usage

local user_name = DCEI.GetUserName()
DCEI.LogMessage(user_name)

string GetUserTag() {string-GetUserTag}

string GetUserTag()

Description

Returns the player's tag.

Example Usage

local user_tag = DCEI.GetUserTag()
DCEI.LogMessage(user_tag)

void WildCastleCreateGuild(string guildName, TypedCallback prepareCallback, TypedCallback<object> resultCallback) {void-WildCastleCreateGuildstring-guildName-TypedCallback-prepareCallback-TypedCallbackobject-resultCallback}

void WildCastleCreateGuild(string guildName, TypedCallback prepareCallback, TypedCallback<object> resultCallback)

Description

Parameters

Example Usage

void WildCastleLeaveGuild(TypedCallback<object> callback) {void-WildCastleLeaveGuildTypedCallbackobject-callback}

void WildCastleLeaveGuild(TypedCallback<object> callback)

Description

Parameters

Example Usage

void WildCastlePullGuild(TypedCallback<object> callback) {void-WildCastlePullGuildTypedCallbackobject-callback}

void WildCastlePullGuild(TypedCallback<object> callback)

Description

Parameters

Example Usage

void WildCastleSearchGuild(string guildNameOrTag, TypedCallback<object> callback) {void-WildCastleSearchGuildstring-guildNameOrTag-TypedCallbackobject-callback}

void WildCastleSearchGuild(string guildNameOrTag, TypedCallback<object> callback)

Description

Parameters

Example Usage

void WildCastleApplyForGuild(string guildId, TypedCallback<object> callback) {void-WildCastleApplyForGuildstring-guildId-TypedCallbackobject-callback}

void WildCastleApplyForGuild(string guildId, TypedCallback<object> callback)

Description

Parameters

Example Usage

void WildCastlePullGuildApplicants(TypedCallback<object> callback) {void-WildCastlePullGuildApplicantsTypedCallbackobject-callback}

void WildCastlePullGuildApplicants(TypedCallback<object> callback)

Description

Parameters

Example Usage

void WildCastleResponseToJoinGuild(string targetPlayerUuid, bool accept, TypedCallback<object> callback) {void-WildCastleResponseToJoinGuildstring-targetPlayerUuid-bool-accept-TypedCallbackobject-callback}

void WildCastleResponseToJoinGuild(string targetPlayerUuid, bool accept, TypedCallback<object> callback)

Description

Parameters

Example Usage

void WildCastleKickOutGuildMember(string targetPlayerUuid, TypedCallback<object> callback) {void-WildCastleKickOutGuildMemberstring-targetPlayerUuid-TypedCallbackobject-callback}

void WildCastleKickOutGuildMember(string targetPlayerUuid, TypedCallback<object> callback)

Description

Parameters

Example Usage

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