Page 1 of 1

Update Dialogue System Variable on Hover

Posted: Tue Dec 17, 2024 5:53 am
by rig
Hey there,

I recently purchased your great asset and I'm trying to modify it a little to fit my needs more.

I am building this on your example of Hover over the dialogue option. However, I want to use PlayMaker for more control over what is being shown on the canvas I activate when hovering over (also using your example to activate the GameObject with my FSM).

What I want to do is update the "skillToCheck" variable within the Dialogue System to whatever is typed in the Description or another Custom Field I have on the Dialogue Entry. I want this to be updated on hover so then my PlayMaker FSM (also activated on hover) can just get the dialogue system variable from the dialogue system so I can further use it in my FSM.

I don't know if I've made myself clear and sorry if I am confusing you but basically I want the skillToCheck Dialogue System variable to change to whatever the description or another field is on the Dialogue Entry.

Hope I have made myself clear,
Thank you! :D

Re: Update Dialogue System Variable on Hover

Posted: Tue Dec 17, 2024 8:00 am
by Tony Li
Hi,

It might be easier with a bit of code rather than Playmaker. But you could always turn the code into a custom Playmaker action. Putting a script like this on the Dialogue Manager should do it:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class SetSkillToCheckVariable : MonoBehaviour
{
    public void OnConversationLine(Subtitle subtitle)
    {
        var skillToCheck = Field.LookupValue(subtitle.dialogueEntry.fields, "Description");
        DialogueLua.SetVariable("skillToCheck", skillToCheck);
    }
}
It sets the DS variable "skillToCheck" to the value of the current dialogue entry's Description field.

Re: Update Dialogue System Variable on Hover

Posted: Tue Dec 17, 2024 8:30 am
by rig
This doesn't seem to work.
The variable is not updated even if I hover or if I select the response.

The reason I want to use PlayMaker and sync the string from Dialogue System to PlayMaker variable is to make it easier for me to use templates for skill checks I make within PlayMaker.

Is there a way I can modify the already ActivateOnResponseHover.cs script from your example to update the Dialogue System variable on hover?

I'm not great at coding... (hence the usage of PlayMaker :) )

Re: Update Dialogue System Variable on Hover

Posted: Tue Dec 17, 2024 9:13 am
by Tony Li
Hi,

Sure, change this line:

Code: Select all

if (tooltip != null) tooltip.text = Field.LookupValue(response.destinationEntry.fields, "Description");
to this:

Code: Select all

var skillToCheck = Field.LookupValue(response.destinationEntry.fields, "Description");
if (tooltip != null) tooltip.text = skillToCheck;
DialogueLua.SetVariable("skillToCheck", skillToCheck);
If you don't want to use the "Description" field, change "Description" to the name of the field you want to use.