Page 1 of 1
Lua Error threw exception
Posted: Sun Jan 05, 2020 9:51 am
by Stalker_EG
Good afternoon.
When trying to execute lua code:
Actor["Dan"].Dan/main/satiety = 0
get this error:
Dialogue System: Lua code 'Actor["Dan"].Dan/main/satiety = 0' threw exception 'Code has syntax errors:
Line 2, Col 1 : Failed to parse Letter of Name.
Line 2, Col 1 : Failed to parse Name of VarName.
Line 2, Col 1 : Failed to parse 'nil' of NilLiteral.
Line 2, Col 1 : Failed to parse Text of BoolLiteral.
Line 2, Col 1 : Failed to parse '0'...'9' of Digit.
Line 2, Col 1 : Failed to parse (Digit)+ of FloatNumber.
What am I doing wrong? The code is compiled by a wizard inside the dialog editor.
Re: Lua Error threw exception
Posted: Sun Jan 05, 2020 10:22 am
by Tony Li
Hi,
The Dialogue System doesn't currently handle forward slashes ( / ) in custom field names. I'll add support for this into the next update.
Re: Lua Error threw exception
Posted: Sun Jan 05, 2020 10:36 am
by Stalker_EG
Tell me, how can we get out of this situation now?? change all the variables?
It's just that the description says "/" is supported everywhere for the convenience of the structure.
I could not even think that Lua does not support it. I have all the variables in all the tables so grouped.
Re: Lua Error threw exception
Posted: Sun Jan 05, 2020 11:21 am
by Tony Li
I'll send you a patch later today
Re: Lua Error threw exception
Posted: Sun Jan 05, 2020 11:31 am
by Stalker_EG
Oh, this is gonna be awesome! I've already broken my head about how to get out of this situation.
I'm sorry I must have loaded you with work. But I really couldn't imagine that this format wasn't supported. I'm sorry. I'm looking forward to that patch. Thank you so much for that level of support.
Re: Lua Error threw exception
Posted: Sun Jan 05, 2020 12:07 pm
by Tony Li
Hi,
Here's the patch:
DialogueSystem_2_2_4_Patch20200105.unitypackage
At runtime, fields with forward slashes such as "Dan/main/satiety" will use underscores in Lua such as "Dan_main_satiety". You do
not need to change the field name in the Actors section. When you use the "..." wizard to generate
new Conditions and Script expressions, they will now be correctly generated as:
However, you will need to update any existing Conditions and Script fields. Here are some ways to do this:
1. Manually edit the Conditions or Script field and replace "/" with "_".
2. Or delete the old expression and use "..." to generate it again.
3. Or use the Database section's Global Search & Replace feature. Replace ".Dan/main/satiety" with ".Dan_main_satiety". NOTE: The "." in front is very important. Otherwise it will also replace the actual field name in the Actors section, which you do not want to do.
Re: Lua Error threw exception
Posted: Sun Jan 05, 2020 12:13 pm
by Stalker_EG
Thank you again so much for your support! I'm going to check it out and let you know the result.
Re: Lua Error threw exception
Posted: Sun Jan 05, 2020 12:28 pm
by Stalker_EG
works! It's perfect.
I hope that doesn't change in the next update?
Thank you so much!
Re: Lua Error threw exception
Posted: Sun Jan 05, 2020 12:54 pm
by Tony Li
This same fix will also be in the next version.