Events

You can track events that occur when the user presses certain buttons in the game.

Available events and methods to work with them:

1ysdk = {
2    on_event = function (eventName: "EXIT" | "HISTORY_BACK", listener: function): nil,
3    dispatch_event = function (eventName: "EXIT" | "HISTORY_BACK", detail: table|nil): nil
4}

HISTORY_BACK

Alert

The event is only available if the game is launched on a TV.

To track a press of the Back button, use the method:

1ysdk.on_event("HISTORY_BACK", function (self)
2    -- Showing the custom game dialog to the user with the options
3    -- to confirm exiting the game, going to the internal settings, store, and so on.
4end)

EXIT

If the user confirmed exiting the game in the custom dialog that opened after pressing Back, the game must send the exit event. To do this, use the method:

ysdk.dispatch_event("EXIT")

Repository