@@ -8,14 +8,17 @@ extends Resource
8
8
## Load it from the text file with [method Dialogue.load], or write it directly in script using [method Dialogue.new]
9
9
## [codeblock]
10
10
## var dlg = Dialogue.load("res://your_dialogue.dlg")
11
- ##
11
+ ## # or
12
12
## var dlg = Dialogue.new("""
13
13
##
14
14
## Godette:
15
15
## "Hello world!"
16
16
##
17
17
## """)
18
18
## [/codeblock]
19
+ ##
20
+ ## @tutorial(Dialogue Syntax): https://nndda.github.io/Theatre/class/dialogue/syntax/
21
+ ## @tutorial(Theatre's tutorial page): https://nndda.github.io/Theatre/tutorials/
19
22
20
23
#region NOTE: Stored variables ---------------------------------------------------------------------
21
24
@export_storage var _sets : Array [Dictionary ] = []
@@ -82,11 +85,9 @@ func get_source_path() -> String:
82
85
## Returns word count in the compiled [Dialogue]. Optionally pass [param variables] to insert
83
86
## variables used by the [Dialogue], otherwise it will count any variable placeholder as 1 word.
84
87
func get_word_count (variables : Dictionary = {}) -> int :
85
- var regex := RegEx .new ()
86
- regex .compile (r "\w +" )
87
-
88
- # is it really any better?
89
- return regex .search_all (_strip (
88
+ return RegEx \
89
+ .create_from_string (r "\w +" ) \
90
+ .search_all (_strip (
90
91
variables .merged (Stage ._VARIABLES_BUILT_IN ),
91
92
true , true
92
93
)).size ()
@@ -104,13 +105,13 @@ func get_sections() -> Dictionary:
104
105
105
106
func _update_used_function_calls () -> void :
106
107
for n : Dictionary in _sets :
107
- for m : Dictionary in n ["func" ]:
108
- if ! _used_function_calls .has (m ["caller" ]):
109
- _used_function_calls [m ["caller" ]] = {}
108
+ for m : Dictionary in n [DialogueParser . __FUNC ]:
109
+ if ! _used_function_calls .has (m [DialogueParser . __CALLER ]):
110
+ _used_function_calls [m [DialogueParser . __CALLER ]] = {}
110
111
111
- _used_function_calls [m ["caller" ]][m ["ln_num" ]] = {
112
- "name" : m ["name" ],
113
- "args" : m ["args" ],
112
+ _used_function_calls [m [DialogueParser . __CALLER ]][m [DialogueParser . __LN_NUM ]] = {
113
+ DialogueParser . __NAME : m [DialogueParser . __NAME ],
114
+ DialogueParser . __ARGS : m [DialogueParser . __ARGS ],
114
115
}
115
116
116
117
## Gets all variables used in the written [Dialogue].
@@ -119,7 +120,7 @@ func get_variables() -> PackedStringArray:
119
120
120
121
func _update_used_variables () -> void :
121
122
for n : Dictionary in _sets :
122
- for m : String in n ["vars" ]:
123
+ for m : String in n [DialogueParser . __VARS ]:
123
124
if not m in _used_variables :
124
125
_used_variables .append (m )
125
126
@@ -145,8 +146,7 @@ func _strip(
145
146
) + n .line + newline + newline
146
147
147
148
# Strip BBCode tags
148
- for bb in DialogueParser ._regex_bbcode_tags .search_all (output ):
149
- output = output .replace (bb .strings [0 ], DialogueParser .EMPTY )
149
+ output = DialogueParser ._regex_bbcode_tags .sub (output , DialogueParser .EMPTY , true )
150
150
151
151
return output .format (variables )
152
152
0 commit comments