Page 1 of 1

Changing menu text on specific node during conversation

Posted: Fri Jun 26, 2020 6:04 am
by Lyl
Hello Tony,

I'm pretty of sure I'm not the first one to ask this question, but I couldn't find the answer for this specific predicament on the forum - sorry for the redundancy.

I'm trying to change the menu text of a response menu linked to a custom panel(which stays active but disabled if conditions if false), depending on a given Variable.

For example, lua:

Code: Select all

if (Variable["varSmart"] < 2) then (insertAWayToAccessMenuTextHere) = "you're not smart enough"
condition:

Code: Select all

Variable["varSmart"] >= 2
I realize the simple fix would be to create another "clone" node with a condition, but since both nodes would use the same custom panel, and both nodes would be set to appear on screen whether the condition is met or not, I'm assuming it'll be an issue.

Another fix I had in mind was to use a text Variable in the menu text, and use something like

Code: Select all

 if (Variable["varSmart"] < 2) then Variable["text Variable"] = "You're not smart enough"
but I wasn't able to make the "if then" syntax works in lua... :oops:

Anyway, that's my little issue right now ^^

Thank you

Re: Changing menu text on specific node during conversation

Posted: Fri Jun 26, 2020 10:07 am
by Tony Li
Hi,

Let's see if we can get it working the usual way, using two response nodes with different Conditions (Variable["varSmart"] < 2 and Variable["varSmart"] >= 2). If you do this, what happens that you don't want to happen?

Re: Changing menu text on specific node during conversation

Posted: Sat Jun 27, 2020 8:33 am
by Lyl
Well, I found the perfect solution thanks to your latest tutorial (I hope you'll keep making those), by making a very simple custom lua script which worked like a charm!

I tried to use two response nodes (both of them using the same custom menu panel), one showing even when invalid(the one saying "not smart enough"), the other not showing if invalid(the one allowing to keep the dialogue going if smart enough); but only one was activated, so when the other menu would be valid, it wouldn't appear on screen. The solution was to make a duplicate of the custom menu panel, and instead of both node using [position=x]; setting one [position=x], the other [position=y].
Which worked, but was a bit of a stretch.

The other solution was also to make two response nodes, the same way, and setting the false condition action to Passthrough one the not showing on invalid.

But the custom lua script is too good of a tool not to use it, so I just made something like:

Code: Select all

public void changeCustomText(string textFail, string textSucceed, double statRequired)
    {
        
        statClass = DialogueLua.GetVariable("smart").AsInt;
        

        if (statClass > statRequired)
        {
            DialogueLua.SetVariable("customText", textSucceed);
        }
        else { DialogueLua.SetVariable("customText", textFail);
        }
    }
    

and it worked as expected.

Anyway, sorry for adding noise to the forum for a problem with so many solutions...

And thanks for your attention!


Have a good day

Re: Changing menu text on specific node during conversation

Posted: Sat Jun 27, 2020 11:05 am
by Tony Li
Glad to help!