Page 1 of 1

Bark condition always false

Posted: Sat May 06, 2023 1:18 pm
by lupiyo
Hello!

I'm having trouble on get the true condition to bark works, i'm using a custom function (which is registered on lua) that return a string with the enemy type, which is Wolf. In the dialog inspector, the condition to trigger the bark is always false, even if the type is Wolf.

I managed to show debug info message from bark in dialog manager, so i could see that the condition is false and blocking.
I have printed the function output and it gives the string "Wolf'. I will post some pictures.

And when i delete the condition, the bark works fine! :/

Also, when I create a conditional using the 3 dots, it returns me my function with double parenteses like ()() in the end, are my function registered incorrectly?

Am I using the condition wrong? Thanks!
Barks 13.JPG
Barks 13.JPG (31.24 KiB) Viewed 162 times
Barks 12.JPG
Barks 12.JPG (10.5 KiB) Viewed 162 times
Barks 11.JPG
Barks 11.JPG (12.23 KiB) Viewed 162 times
Barks 10.JPG
Barks 10.JPG (20.02 KiB) Viewed 162 times

Re: Bark condition always false

Posted: Sat May 06, 2023 1:41 pm
by Tony Li
Hi,

Does it print:

Code: Select all

GetEnemyRace() == "Wolf"
in the same operation as the Block On False Link, or are you calling GetEnemyRace() yourself, such as in another script?

Is it possible that the race is set to "Wolf " with a blank space at the end or something?

To fix the double parentheses error, remove "()" from the end of the function name in you Custom Lua Function Info asset.

Re: Bark condition always false

Posted: Sat May 06, 2023 3:29 pm
by lupiyo
in the same operation as the Block On False Link, or are you calling GetEnemyRace() yourself, such as in another script?
Sorry, I didn't get the question.

About the possibility of having some trash or space, I changed the return value as "Wolf", in hard code and this worked. But when i return as showed on previous print it didn't. The value is Wolf too, and even with Trim didn't work. Is there a way to transform into string in the Condition Field?

The string orign is an Enum type, that has races on it, and i'm passing as parameter it with ToString() in the lua register function.

Also, i found and warning message, I dont't know if it is related.

Code: Select all

Dialogue System: Registering transform Dark Wolf (10) as actor 'NPC' but another transform is already registered. Overwriting with new transform.
UnityEngine.Debug:LogWarning (object,UnityEngine.Object)
PixelCrushers.DialogueSystem.CharacterInfo:RegisterActorTransform (string,UnityEngine.Transform) (at Assets/Dialogs/Files/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Model/Logic/Shared/CharacterInfo.cs:177)
PixelCrushers.DialogueSystem.DialogueActor:OnEnable () (at Assets/Dialogs/Files/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Actor/DialogueActor.cs:152)
I have more than one monster, should i have one actor name per monster? (the monster barsk, like wolf)

Thank you!

Re: Bark condition always false

Posted: Sat May 06, 2023 8:00 pm
by Tony Li
Hi,

A few notes/questions:

Lua functions are registered globally. You can't register GetEnemyRace() on one GameObject and then try to register the same function name on a different GameObject.

In your GetEnemyRace() method, how are you determining the value of the variable "enemy"?

Here's an example scene:

DS_GetRaceNameExample_2023-05-06.unitypackage

You can click on the Cube (a "Wolf") or the Sphere (a "Cow"). When a bark starts, it sets Variable["Actor"] to the name of the barking actor (e.g, "Wolf" or "Cow"). In this example, the GetRaceName() method returns the value of Variable["Actor"]. This is a bit redundant, since your Conditions in this case could just check Variable["Actor"] directly.