项目

一般

简介

SaveVar » 历史记录 » 版本 8

tejie, 2026-01-06 09:29

1 2 yangdefeng
h4. _*%{color:green}saveVar%*_
2 3 yangdefeng
3 5 tejie
将指定的自定义变量保存到指定文件中,变量名不支持解析
4 1 machenhe
5 8 tejie
标签:命令^saveVar
6 1 machenhe
7 8 tejie
*相关命令*
8
[[saveVar1]]
9
10 1 machenhe
*格式*
11
|命令名	|参数1		|参数2		|参数3		|
12
|saveVar|变量作用域	|自定义变量名	|保存文件路径	|
13
14
*说明*
15 8 tejie
|/5^.参数1|\3.设置自定义变量的[[自定义变量#自定义变量作用域|作用域]]|
16
|guild |行会|服务器重启时,会清除,需要重新读取。  |
17
|guild2|行会|无需保存文件,服务器重启时,不会清除。|
18
|human |个人|服务器重启时,会清除,需要重新读取。  |
19
|global|全局|无需保存文件,服务器重启时,不会清除。|
20
|参数2|\3.指定的自定义变量名,不支持变量解析。|
21
|参数3|\3.指定的文件保存路径|
22
|\4. %{color:deepPink}注:此命令在一个文件中,一个玩家只能保存一个变量%|
23 1 machenhe
24
25
-
26
-
27
28 2 yangdefeng
h4. *%{color:deepskyblue}特戒引擎脚本示例:%*
29 1 machenhe
30
bq. [<notextile>@</notextile>main]
31
#act
32 2 yangdefeng
[[mov]] s$filePath ..QuestDiary\loadVar测试.txt
33 1 machenhe
#say
34
<text:变量保存:50:50/<notextile>@</notextile>按钮1>
35
<text:变量读值:50:150/@按钮2>
36
%{color:lightgrey};--保存数据%
37
[<notextile>@</notextile>按钮1]
38
#act
39 2 yangdefeng
[[calcVar]] human 个人捐款 = 9999
40
*{color:green}saveVar* human 个人捐款 s$filePath
41
[[sendMsg]] 6 赋值完毕
42 1 machenhe
%{color:lightgrey};--此处可重启服务器,测试数据是否保存%
43
[<notextile>@</notextile>按钮2]
44
#act
45 2 yangdefeng
[[loadVar]] human 个人捐款 s$filePath
46
[[sendMsg]] 6 <notextile>%</notextile>s个人捐款:<$human(个人捐款)>
47 3 yangdefeng
48
-
49
-
50
51
h4. *%{color:deepskyblue}特戒引擎脚本示例:%*
52
53
bq. [<notextile>@</notextile>main]
54 4 yangdefeng
#act
55
[[mov]] s$filePath \数据文件\非预制数据文件.txt
56
&nbsp;
57
#say
58
<notextile><变量保存@变量保存>\ \</notextile>
59
<notextile><变量读值@变量读值>\ \</notextile>
60
<notextile><变量输出@变量输出>\ \</notextile>
61
<notextile><删除文件@删除文件>\ \</notextile>
62
&nbsp;
63
<notextile>[@变量保存]</notextile>
64
#if
65
#act
66
[[calcVar]] human 个人捐款 = 9999
67
*{color:green}saveVar* human 个人捐款 s$filePath
68
[[print]] 保存完毕
69
&nbsp;
70
<notextile>[@变量读值]</notextile>
71
#if
72
[[fileExist]] <$str(s$filePath)>
73
#act
74
[[calcVar]] human 个人捐献 = 1111
75
[[loadVar]] human 个人捐款 s$filePath
76
[[print]] %s个人捐献:<$human(个人捐款)>
77
#elseAct
78
[[print]] 不存在该文件
79
&nbsp;
80
<notextile>[@变量输出]</notextile>
81
#act
82
[[print]] %s个人捐献:<$human(个人捐款)>
83
&nbsp;
84
<notextile>[@删除文件]</notextile>
85
#act
86
[[clearFile]] s$filePath
87
[[print]] 文件已删除