-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
176 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
"out", | ||
"dist", | ||
"3rd", | ||
"**/*.d.ts" | ||
"**/*.d.ts", | ||
"template" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
let y3 = require('y3-helper') | ||
|
||
// 定义一个函数,然后点击运行函数按钮即可执行 | ||
async function example() { | ||
//1. 先来创建一个新的单位 | ||
let unitTable = y3.table.openTable('单位') // 打开单位表 | ||
|
||
// 创建单位需要一些时间(往硬盘写入文件),因此需要加上 await | ||
let unit1 = await unitTable.create({ | ||
name: '演示单位1', // 起个名字 | ||
key: 11037, // 这个单位的key,如果不填,会自动生成一个可用的key | ||
overwrite: true, // 如果指定了key,是否允许覆盖已有的单位;否则可能会创建失败 | ||
}) | ||
|
||
y3.print('演示单位1创建完成', unit1) | ||
|
||
//2. 复制一个已有的单位 | ||
let unit2 = await unitTable.create({ | ||
copyFrom: unit1, // 要复制的单位,也可以用数字key | ||
name: '演示单位2', | ||
key: 11038, | ||
overwrite: true, | ||
}) | ||
|
||
y3.print('演示单位2创建完成', unit2) | ||
|
||
//3. 修改单位的数据 | ||
unit2.data.ori_speed = 5 // 修改移动速度 | ||
|
||
y3.print('移动速度修改完成') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters