75 lines
1.9 KiB
Markdown
75 lines
1.9 KiB
Markdown
---
|
||
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)
|
||
```
|
||
|
||
|
||
|