Lua Error threw exception

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Stalker_EG
Posts: 31
Joined: Sun Jul 07, 2019 7:57 pm

Lua Error threw exception

Post 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.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua Error threw exception

Post 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.
User avatar
Stalker_EG
Posts: 31
Joined: Sun Jul 07, 2019 7:57 pm

Re: Lua Error threw exception

Post 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.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua Error threw exception

Post by Tony Li »

I'll send you a patch later today
User avatar
Stalker_EG
Posts: 31
Joined: Sun Jul 07, 2019 7:57 pm

Re: Lua Error threw exception

Post 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.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua Error threw exception

Post 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:

Code: Select all

Actor["Dan"].Dan_main_satiety = 0
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.
User avatar
Stalker_EG
Posts: 31
Joined: Sun Jul 07, 2019 7:57 pm

Re: Lua Error threw exception

Post by Stalker_EG »

Thank you again so much for your support! I'm going to check it out and let you know the result.
User avatar
Stalker_EG
Posts: 31
Joined: Sun Jul 07, 2019 7:57 pm

Re: Lua Error threw exception

Post by Stalker_EG »

works! It's perfect.
I hope that doesn't change in the next update?
Thank you so much!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua Error threw exception

Post by Tony Li »

This same fix will also be in the next version.
Post Reply