Accessing Quest variable from lua inside the db editor
-
- Posts: 91
- Joined: Tue Jul 14, 2015 8:22 am
Accessing Quest variable from lua inside the db editor
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
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
If you want the dialogue to be allowed or blocked by the boolean, in the Condition field you would have:
Or, if you want to change the boolean value, you can use the script field to make changes to variables and quest states, etc.
- it's best to use the drop-down menu for adding fields to conditions and scripts.
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
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:
If the quest doesn't have a Return field, it will return nil, which is the "undefined" value.
- Conditions: Quest["Holy_Grail"].Return == true
If the quest doesn't have a Return field, it will return nil, which is the "undefined" value.
-
- Posts: 91
- Joined: Tue Jul 14, 2015 8:22 am
Re: Accessing Quest variable from lua inside the db editor
Perfect, thanks guys.
-
- Posts: 91
- Joined: Tue Jul 14, 2015 8:22 am
Re: Accessing Quest variable from lua inside the db editor
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
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
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:
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]");
-
- Posts: 91
- Joined: Tue Jul 14, 2015 8:22 am
Re: Accessing Quest variable from lua inside the db editor
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.
Here's what I have in the Dialogue entry, it spits this out literally in-game.
- Attachments
-
- dialogue.PNG (21.49 KiB) Viewed 1411 times
Re: Accessing Quest variable from lua inside the db editor
Hi,
Try changing your Dialogue Text to: Hey [var=player_name]
Try changing your Dialogue Text to: Hey [var=player_name]
-
- Posts: 91
- Joined: Tue Jul 14, 2015 8:22 am
Re: Accessing Quest variable from lua inside the db editor
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?
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?
-
- Posts: 91
- Joined: Tue Jul 14, 2015 8:22 am
Re: Accessing Quest variable from lua inside the db editor
Never mind, it was the way this was being parsed at the text box end.