Update Dialogue System Variable on Hover

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
rig
Posts: 2
Joined: Thu Nov 21, 2024 8:48 am

Update Dialogue System Variable on Hover

Post 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
Attachments
Screenshot 2024-12-17 at 12.45.17.png
Screenshot 2024-12-17 at 12.45.17.png (171.68 KiB) Viewed 409 times
Screenshot 2024-12-17 at 12.44.33.png
Screenshot 2024-12-17 at 12.44.33.png (83.69 KiB) Viewed 409 times
User avatar
Tony Li
Posts: 23256
Joined: Thu Jul 18, 2013 1:27 pm

Re: Update Dialogue System Variable on Hover

Post 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.
rig
Posts: 2
Joined: Thu Nov 21, 2024 8:48 am

Re: Update Dialogue System Variable on Hover

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

Re: Update Dialogue System Variable on Hover

Post 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.
Post Reply