环境变量

您可以获取有关游戏环境的信息。为此,请使用 environment 对象。

 1{
 2  app: {
 3    id: string;
 4  };
 5  i18n: {
 6    lang: string;
 7    tld: string;
 8  };
 9  payload?: string;
10}

environment 对象

包含游戏环境变量。

参数

类型

描述

app

object

游戏数据。

i18n

object

服务国际化。

payload

string

游戏地址的 payload 参数值。可选。例如,在 https://yandex.ru/games/app/123?payload=test 中,您可以按如下所示返回 testysdk.environment.payload

app 结构

参数

类型

描述

id

string

游戏 ID。

i18n 结构

参数

类型

描述

lang

string

ISO 639-1 格式的 Yandex Games 界面语言。例如,"tr" 表示游戏当前正在 Yandex Games 土耳其语界面下运行。此参数用于自动确定游戏中用户的语言(项 2.14)。

示例

1const ysdk = (await YaGames.init());
2const lang = ysdk.environment.i18n.lang; // 'en', 'ru', ...

备注

技术支持团队将协助您将已完成的游戏发布到 Yandex 游戏平台。关于开发和测试方面的具体问题,其他开发人员将在Discord 频道中进行回答。

如果您遇到 Yandex Games SDK 方面的问题或有其他问题想要咨询,请联系支持部门:

写入聊天信息

游戏数据。

游戏 ID。

服务国际化。

ISO 639-1 格式的 Yandex Games 界面语言。例如,"tr" 表示游戏当前正在 Yandex Games 土耳其语界面下运行。建议使用此参数确定用户在游戏中使用的语言。

顶级域。例如,"com" 表示游戏当前正在 Yandex Games 国际域下运行。在您的域中托管游戏时,请注意,游戏必须能够在任何 Yandex 域下正确打开。

游戏地址的 payload 参数值。 可选。 例如,在 https://yandex.ru/games/app/123?payload=test 中,您可以按如下所示返回 testysdk.environment.payload