Trigger API Reference DCEI Functions Service0 - BLKTower/TestWiki GitHub Wiki
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)
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.
-
string
key
the localization key to use. -
Dictionary
parameters
(optional) a table of replacement text keys.
-- 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()
Returns true if ads are ready.
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)
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.
-
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.
function ResolveAds(success)
if success then
-- deliver ad rewards to player
else
-- show error message for player
end
end
DCEI.ShowAds(ResolveAds)
bool IsOnline()
Returns true if the user currently has internet access. This can be simulated in Play Settings.
local is_online = DCEI.IsOnline()
if is_online then
DCEI.LogMessage(tostring(is_online))
end
bool IsDev()
Returns true if the user currently has developer access. This can be simulated in Play Settings.
local is_dev = DCEI.IsDev()
if is_dev then
DCEI.LogMessage(tostring(is_dev))
end
void ShowSettings()
Show the game settings menu. Only works on mobile.
DCEI.ShowSettings()
void GetSaveDataHistory(int count, TypedCallback<object> callback) {void-GetSaveDataHistoryint-count-TypedCallbackobject-callback}
void GetSaveDataHistory(int count, TypedCallback<object> callback)
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.
-
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.
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)
Attempts to resets the saved map data at the given index.
DCEI.ResetSavedMapDataByIndex(1)
void GetMail(TypedCallback<object> callback, bool forceFetch) {void-GetMailTypedCallbackobject-callback-bool-forceFetch}
void GetMail(TypedCallback<object> callback, bool forceFetch)
Attempts to fetch the player's mail. If successful, the callback will return with the save history as a table as its first parameter.
-
object
callback
the callback function to handle the returned mail. -
bool
forceFetch
if true, forces a fetch.
function MailHandler(result)
--Handle mail
end
DCEI.GetMail(MailHandler, false)
void DeleteMail(int instanceId)
Attempts to delete the mail with the given ID.
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)
Schedules a notification and returns the ID of said notification. Only works on mobile.
-
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.
DCEI.ScheduleNotification("Title", "Notification", 120)
void CancelNotification(int id)
Cancels a notification from the given id. Only works on mobile.
DCEI.CancelNotification(1)
object GetLastNotificationId()
Returns the last notification ID. Only works on mobile.
local last_notif_id = DCEI.GetLastNotificationId()
void ShowSendSMS(int platform)
Shows the SMS invitation screen. Only works on mobile or web builds.
DCEI.ShowSendSMS(1)
void RestartApplication()
Restarts the application. Only works on mobile.
DCEI.RestartApplication()
void OpenUrl(string url)
Opens a web url in the user's default browser.
DCEI.OpenUrl("http://localhost:7777/Wiki/TestBranch/Trigger-API-Reference-DCEI-Functions-Service0#openurl")
void RequestAppStoreReview()
Requests an app store review. Only works on iOS devices.
DCEI.RequestAppStoreReview()
void RequestInAppReview(Action successCallback, Action failureCallback) {void-RequestInAppReviewAction-successCallback-Action-failureCallback}
void RequestInAppReview(Action successCallback, Action failureCallback)
Requests an in-app review. Only works on iOS devices.
-
Action
successCallback
the action that is taken on a successful review. -
Action
failureCallback
the action that is taken on a failed review.
DCEI.RequestInAppReview(SuccessCallback, FailureCallback)
void GetServerTime(TypedCallback<int> callback)
Attempts to return the server time as the first parameter of a callback function.
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()
Returns the player's internal user ID. This can be simulated in Play Settings.
local user_id = DCEI.GetUserId()
DCEI.LogMessage(user_id)
string GetUserName()
Returns the player's username.
local user_name = DCEI.GetUserName()
DCEI.LogMessage(user_name)
string GetUserTag()
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)
void WildCastleLeaveGuild(TypedCallback<object> callback) {void-WildCastleLeaveGuildTypedCallbackobject-callback}
void WildCastleLeaveGuild(TypedCallback<object> callback)
void WildCastlePullGuild(TypedCallback<object> callback) {void-WildCastlePullGuildTypedCallbackobject-callback}
void WildCastlePullGuild(TypedCallback<object> callback)
void WildCastleSearchGuild(string guildNameOrTag, TypedCallback<object> callback) {void-WildCastleSearchGuildstring-guildNameOrTag-TypedCallbackobject-callback}
void WildCastleSearchGuild(string guildNameOrTag, TypedCallback<object> callback)
void WildCastleApplyForGuild(string guildId, TypedCallback<object> callback) {void-WildCastleApplyForGuildstring-guildId-TypedCallbackobject-callback}
void WildCastleApplyForGuild(string guildId, TypedCallback<object> callback)
void WildCastlePullGuildApplicants(TypedCallback<object> callback) {void-WildCastlePullGuildApplicantsTypedCallbackobject-callback}
void WildCastlePullGuildApplicants(TypedCallback<object> callback)
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)
void WildCastleKickOutGuildMember(string targetPlayerUuid, TypedCallback<object> callback) {void-WildCastleKickOutGuildMemberstring-targetPlayerUuid-TypedCallbackobject-callback}
void WildCastleKickOutGuildMember(string targetPlayerUuid, TypedCallback<object> callback)