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