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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-extra-actions",
3
- "version": "0.3.24",
3
+ "version": "0.3.25",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "勾选动作库里的动作,写进形象包的「额外动作拓展」文件夹,让桌宠照着做。自带入门形象包与示例动作;完整 105 段可一键下载安装(不用解压、不用选文件夹)。",
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
- // (旧逻辑是「删掉所有没被勾选的 motion 词」,对外来形象包等于摧毁它的词表。)
208
- const mine = new Set(Array.isArray(managed?.added) ? managed.added : []);
209
- const kept = base.filter((w) => !mine.has(w?.id) || wanted.has(w?.id));
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) {
@@ -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 });