项目

一般

简介

SaveVar » 历史记录 » 版本 4

yangdefeng, 2023-08-04 14:39

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