cortico-world-extra-actions 0.3.24 → 0.3.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/writer.js +16 -4
- package/tools/test_issue3.mjs +8 -0
package/package.json
CHANGED
package/src/writer.js
CHANGED
|
@@ -203,10 +203,22 @@ function applyVocab(packDir, actions, managed) {
|
|
|
203
203
|
const base = (clean && Array.isArray(managed.baseVocab)) ? managed.baseVocab : current;
|
|
204
204
|
|
|
205
205
|
const wanted = new Set(actions.map((a) => a.word).filter(Boolean));
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
// 判据不是「谁加的」,而是「这段动作还在不在包里」:
|
|
207
|
+
// - 勾了的:留;
|
|
208
|
+
// - 没勾但包里还有这段模块(身体状态、别人自带动作):也留 —— 不能替人删词;
|
|
209
|
+
// - 没勾且模块已经删掉:这才回收,免得 bot 点名一个不存在的动作。
|
|
210
|
+
const hasModule = (id) => {
|
|
211
|
+
if (!id) return false;
|
|
212
|
+
for (const base of [join(packDir, EXTRA_DIR), join(packDir, 'actions')]) {
|
|
213
|
+
try {
|
|
214
|
+
for (const cat of readdirSync(base, { withFileTypes: true })) {
|
|
215
|
+
if (cat.isDirectory() && existsSync(join(base, cat.name, String(id), 'action.json'))) return true;
|
|
216
|
+
}
|
|
217
|
+
} catch { /* 目录不存在就算了 */ }
|
|
218
|
+
}
|
|
219
|
+
return false;
|
|
220
|
+
};
|
|
221
|
+
const kept = base.filter((w) => w?.kind !== 'motion' || wanted.has(w?.id) || hasModule(w?.id));
|
|
210
222
|
const have = new Set(kept.map((w) => w?.id));
|
|
211
223
|
const added = [];
|
|
212
224
|
for (const a of actions) {
|
package/tools/test_issue3.mjs
CHANGED
|
@@ -53,6 +53,14 @@ const ours = makePack('our-pack', {
|
|
|
53
53
|
check(() => assert.equal(W.packLooksSupported(ours), true), '写了 额外动作拓展 的包判为可写');
|
|
54
54
|
|
|
55
55
|
/* ③ 保存:包里原有的 motion 词必须留着,只加我们勾的 */
|
|
56
|
+
// pack 原有的动作补模块
|
|
57
|
+
// 包里原有的动作,真实情况下一定有自己的模块目录(词能对上片段)
|
|
58
|
+
{
|
|
59
|
+
const d = join(ours, 'actions', 'core', 'own-word');
|
|
60
|
+
mkdirSync(d, { recursive: true });
|
|
61
|
+
writeFileSync(join(d, 'action.json'), JSON.stringify({ id: 'own-word', category: 'core', clip: 'actions/core/own-word', frames: 2, seconds: 3 }), 'utf8');
|
|
62
|
+
}
|
|
63
|
+
|
|
56
64
|
const lib = join(root, 'lib');
|
|
57
65
|
const modDir = join(lib, 'actions', 'core', 'cheer-hop');
|
|
58
66
|
mkdirSync(modDir, { recursive: true });
|