Page 1 of 2

Accessing Quest variable from lua inside the db editor

Posted: Tue Mar 27, 2018 5:58 pm
by bluebuttongames
Hi Tony,

So I have a field in some of my quests that's a boolean called "Return".

What would I put in the dialogue tree script field to progress if this particular value of this particular quest is set to true?

Thanks,

BB

Re: Accessing Quest variable from lua inside the db editor

Posted: Tue Mar 27, 2018 7:26 pm
by nathanj
If you want the dialogue to be allowed or blocked by the boolean, in the Condition field you would have:

Code: Select all

Variable["return"] == true


Or, if you want to change the boolean value, you can use the script field to make changes to variables and quest states, etc.

Code: Select all

Variable["return"] = true

- it's best to use the drop-down menu for adding fields to conditions and scripts.

Re: Accessing Quest variable from lua inside the db editor

Posted: Tue Mar 27, 2018 8:21 pm
by Tony Li
Similarly to Nathan's reply, if this is a field in your quest rather than a variable, you'll need to check the Quest[] table instead of the Variable[] table. The "..." dropdowns don't go so far as to handle custom quest fields, so you'll have to type it manually. For example:
  • Conditions: Quest["Holy_Grail"].Return == true
Note that non-alphanumeric characters such as blank spaces should be replaced by underscores, so "Holy Grail" becomes Quest["Holy_Grail"].

If the quest doesn't have a Return field, it will return nil, which is the "undefined" value.

Re: Accessing Quest variable from lua inside the db editor

Posted: Wed Jun 13, 2018 6:01 pm
by bluebuttongames
Perfect, thanks guys.

Re: Accessing Quest variable from lua inside the db editor

Posted: Wed May 22, 2019 4:40 pm
by bluebuttongames
I have a similar problem where a conversation string spits this out:

Hey there Variable["player_name"]

As that's what's in the dialogue editor. Is there something special I need to do to get this as a runtime value?

Thanks,

BB

Re: Accessing Quest variable from lua inside the db editor

Posted: Wed May 22, 2019 4:46 pm
by Tony Li
Hi,

If that's a dialogue entry's Dialogue Text or Menu Text field, or a quest's description or entry fields, then the Dialogue System should automatically replace [var=player_name] with the value of the variable player_name.

(Note that the format is [var=varName].)

If it's another field or a string of your own, call FormattedText.ParseCode to get a version in which [var=varName] and [lua(code)] tags have been replaced with their values:

Code: Select all

string s = FormattedText.ParseCode("Hey there [var=player_name]");

Re: Accessing Quest variable from lua inside the db editor

Posted: Wed May 22, 2019 5:38 pm
by bluebuttongames
That still didn't work, maybe I'm explaining myself poorly.

Here's what I have in the Dialogue entry, it spits this out literally in-game.

Re: Accessing Quest variable from lua inside the db editor

Posted: Wed May 22, 2019 7:04 pm
by Tony Li
Hi,

Try changing your Dialogue Text to: Hey [var=player_name]

Re: Accessing Quest variable from lua inside the db editor

Posted: Sun Dec 08, 2019 8:39 am
by bluebuttongames
Hey, I know it's been a while. I still can't get this working even with that syntax.

I've tried these in my dialogue text field:

"
Variable["player_policeStars"] hours should do it.

[var="player_policeStars"] hours should do it.

[var=player_policeStars] hours should do it.

"
None of those do anything other than the raw code coming through in the text. Is there something I'm missing?

Re: Accessing Quest variable from lua inside the db editor

Posted: Sun Dec 08, 2019 8:44 am
by bluebuttongames
Never mind, it was the way this was being parsed at the text box end.