Files
netease-modsdk-wiki/docs/mcdocs/1-ModAPI/接口/通用/本地存储.md
2025-03-17 13:24:39 +08:00

75 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
sidebarDepth: 1
---
# 本地存储
## GetConfigData
<span style="display:inline;color:#7575f9">客户端</span>
method in mod.client.component.configCompClient.ConfigCompClient
- 描述
获取本地配置文件中存储的数据
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| configName | str | 配置名称只能包含字母、数字和下划线字符另外为了避免addon之间的冲突建议加上addon的命名空间作为前缀 |
| isGlobal | bool | 存档配置or全局配置默认为False |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| dict | 返回本地存储数据 |
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateConfigClient(clientApi.GetLevelId())
configDict = comp.GetConfigData("addon_namespace_global_config_name", True)
```
## SetConfigData
<span style="display:inline;color:#7575f9">客户端</span>
method in mod.client.component.configCompClient.ConfigCompClient
- 描述
以本地配置文件的方式存储数据
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| configName | str | 配置名称只能包含字母、数字和下划线字符另外为了避免addon之间的冲突建议加上addon的命名空间作为前缀 |
| value | dict | 数据 |
| isGlobal | bool | 为True时是全局配置否则为存档配置默认为False |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 是否成功 |
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateConfigClient(clientApi.GetLevelId())
data = {}
data["key"] = "value"
comp.SetConfigData("addon_namespace_global_config_name", data, True)
```