mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-16 03:23:48 +00:00
Updated dialogic
This commit is contained in:
parent
1d11462073
commit
cbb82512ee
483 changed files with 5743 additions and 2177 deletions
|
|
@ -55,13 +55,21 @@ func execute_condition(condition:String) -> bool:
|
|||
return false
|
||||
|
||||
|
||||
var condition_modifier_regex := RegEx.create_from_string(r"(?(DEFINE)(?<nobraces>([^{}]|\{(?P>nobraces)\})*))\[if *(?<condition>\{(?P>nobraces)\})(?<truetext>(\\\]|\\\/|[^\]\/])*)(\/(?<falsetext>(\\\]|[^\]])*))?\]")
|
||||
var condition_modifier_regex := RegEx.create_from_string(r"(?(DEFINE)(?<nobraces>([^{}]|\{(?P>nobraces)\})*))\[if *(?<condition>(\{(?P>nobraces)\}|true\b|false\b))(?<truetext>(\\\]|\\\/|[^\]\/])*)(\/(?<falsetext>(\\\]|[^\]])*))?\]")
|
||||
func modifier_condition(text:String) -> String:
|
||||
for find in condition_modifier_regex.search_all(text):
|
||||
var insert := ""
|
||||
if execute_condition(find.get_string("condition")):
|
||||
text = text.replace(find.get_string(), find.get_string("truetext").strip_edges())
|
||||
insert = find.get_string("truetext")
|
||||
else:
|
||||
text = text.replace(find.get_string(), find.get_string("falsetext").strip_edges())
|
||||
insert = find.get_string("falsetext")
|
||||
|
||||
# Avoid double spaces at the insert position if the insert is empty.
|
||||
if not insert.strip_edges() and " "+find.get_string()+" " in text:
|
||||
text = text.replace(find.get_string()+" ", insert.strip_edges())
|
||||
else:
|
||||
text = text.replace(find.get_string(), insert.strip_edges())
|
||||
|
||||
return text
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue