1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
--- @module pasta.store
--- データストアモジュール
---
--- 全てのランタイムデータを一元管理する。
--- 他のモジュールから require されるが、自身は他モジュールを require しない。
--- これにより循環参照を完全に回避する。
---
--- 注意: 永続化データ(save)はpasta.saveモジュールに移行済み。
--- ctx.saveから参照すること。
--- @class Store
--- @field actors table<string, Actor> アクターキャッシュ(名前→アクター)
--- @field actor_spots table<string, integer> アクターごとのスポット位置マップ(名前→スポットID)
--- @field scenes table<string, table> シーンレジストリ(グローバル名→{ローカル名→シーン関数})
--- @field counters table<string, number> シーン名カウンタ(ベース名→カウンタ値)
--- @field global_words table<string, table> グローバル単語レジストリ(key → values[][])
--- @field local_words table<string, table> ローカル単語レジストリ(scene_name → {key → values[][]})
--- @field actor_words table<string, table> アクター単語レジストリ(actor_name → {key → values[][]})
--- @field app_ctx table アプリケーション実行中の汎用コンテキストデータ
local STORE =
--- アクターキャッシュ(名前→アクター)
--- @type table<string, Actor>
STORE. =
--- アクターごとのスポット位置マップ(名前→スポットID)
--- @type table<string, integer>
STORE. =
--- シーンレジストリ(グローバル名→{ローカル名→シーン関数})
--- @type table<string, table>
STORE. =
--- シーン名カウンタ(ベース名→カウンタ値)
--- @type table<string, number>
STORE. =
--- グローバル単語レジストリ(key → values[][])
--- @type table<string, table>
STORE. =
--- ローカル単語レジストリ(scene_name → {key → values[][]})
--- @type table<string, table>
STORE. =
--- アクター単語レジストリ(actor_name → {key → values[][]})
--- @type table<string, table>
STORE. =
--- アプリケーション実行中の汎用コンテキストデータ
--- @type table
STORE. =
--- 継続用コルーチン(OnTalkチェイントーク用)
--- @type thread|nil
STORE. = nil
--- 最後に実行したグローバルシーン名(選択肢コールバックルーティング用)
--- @type string|nil
STORE. = nil
--- 全データをリセット
--- @return nil
-- CONFIG.actor からの初期化
-- @pasta_config は Rust 組み込みモジュールのため例外扱い(循環参照回避ポリシーの例外)
-- pcall で保護することで、@pasta_config が無い環境(単体テスト等)でも動作可能にする
local ok, CONFIG = pcall
if ok and type == "table"
return STORE