I'm trying to create a dialogue which replaces a variable in the string with a value from another script.
If I want to create a dialogue option which says: "It will cost you X points to do that." and replace X with a value from a database or script or something. What is the best way to do that?
Thanks for your help.
-Mike
Variable in Text
Re: Variable in Text
Hi,
You can define a dialogue database variable named X in the Dialogue Editor window and use a [var=varName] markup tag in your text:
To set X in a C# script, use DialogueLua.SetVariable():
If you need to pull X from a script, register your script function with Lua. Then use the [lua(code)] markup tag:
You can define a dialogue database variable named X in the Dialogue Editor window and use a [var=varName] markup tag in your text:
Code: Select all
"It will cost you [var=X] points to do that."
Code: Select all
using PixelCrushers.DialogueSystem;
...
DialogueLua.SetVariable("X", 42);
Code: Select all
"It will cost you [lua( GetPointCost() )] points to do that."
-
- Posts: 2
- Joined: Sun May 06, 2018 1:21 pm
Re: Variable in Text
Thank you very much for your ultra speedy reply, I'll give that a shot.
-Mike
-Mike
Re: Variable in Text
Glad to help! If you have any questions about it, just let me know.
Re: Variable in Text
Gotta say, this is absolutely amazing. I saw this posted weeks ago and am now just getting to implementing it. We build multiple projects off the same core files, though with different terrains, vegetation, names, language and such. So being able to change the names of generic variables so easily is such an incredibly powerful function.
We no longer need multiple databases for each project, we can have one single database that continually gets updated and improved while the variables are easily switched out for site specific jobs.
Hats off, Tony.
We no longer need multiple databases for each project, we can have one single database that continually gets updated and improved while the variables are easily switched out for site specific jobs.
Hats off, Tony.