你的下一项功能
物品
为所选项目管理独立装备、属性、目录规则与玩家背包。
Godot

可见的结果
保存后目录包含starter_sword。完成核对后的示例购买后,当前背包包含其唯一instanceId。
此步骤尚无视频。指南和MCP请求已可使用。
物品
准备同一个项目
实现此功能
你可以预览指南。运行需要有效的项目密钥。 准备项目
已安装 SDK、导入项目配置,且玩家已登录。
此 SDK 示例使用 develop。请检查已安装的 SDK 是否具备所需 API。
先通过快速入门连接目标玩家,再通过明确的按钮或场景操作调用read_catalog_page(), read_inventory()。仅打开文件不会发送请求。
GDScript
1extends Node
2
3# Connect and restore the existing player first. Each function is an explicit action.
4func read_inventory() -> void:
5 var user = Horizon.auth.getCurrentUser()
6 if user == null:
7 return
8 var result = await Horizon.items.getInventory(user.userId)
9 if not result.success:
10 push_warning(result.errorCode)
11 return
12 for item in result.data.instances:
13 print(item.instanceId, ": ", item.itemKey)
14 # Keep result.data.revision for a separately reviewed mutation.
15
16func read_catalog_page() -> void:
17 var user = Horizon.auth.getCurrentUser()
18 if user == null:
19 return
20 var result = await Horizon.items.getCatalog(user.userId, "", 1)
21 if not result.success:
22 push_warning(result.errorCode)
23 return
24 print("Catalog revision: ", result.data.revision)
25 # Explicit Next retains revision and nextAfterKey; no automatic page loop.
26# Durable mutations: addons/horizon_sdk/examples/features/items_example.gd.
27# Preserve original instance/body/revision and the original PV purchase operationId.
28# Initial success may include item references; retained replay may return empty applied/items.
29# Read the current inventory separately; never reconstruct earlier item references.
30# A failed refresh never authorizes another purchase or a local item grant.
使用已保存的物品
导入官方示例及辅助文件。核对报价后,用现有玩家按下方顺序执行。等待每一步完成,只确认购买一次。响应不确定时保留原始请求。
items_example.gd: load_catalog_page() → review_offer("starter-sword") → purchase_reviewed_offer() → refresh_inventory()
测试你的新功能。
保存后目录包含starter_sword。完成核对后的示例购买后,当前背包包含其唯一instanceId。
在仪表盘中选择与游戏配置相同的项目。


