Page 1 of 1
Dialogue Text Help
Posted: Mon Oct 12, 2015 6:24 pm
by EWalk13
Hi I was just wondering how to incorporate a variables value into the Dialogue Text for a node in a conversation, so the string can be dynamic. I don't know how to use lua that well, but is there a way to script it in the dialogue text box to retrieve the value of a variable?
Re: Dialogue Text Help
Posted: Tue Oct 13, 2015 1:46 pm
by Tony Li
Hi,
Yes, it's really easy. Just use the [var=
varName] tag. For example, say you've defined a number variable in your dialogue database named "PorscheCost" and set the value to 60,000. Then you can set
Dialogue Text to something like:
- Dialogue Text: Interested in that car? It's [var=PorscheCost] dollars.
When you start a conversation, the Dialogue System automatically sets two variables named "Actor" and "Conversant" to the names of the participants. This is useful if you're using the same generic conversation for multiple NPCs, for example a generic Shopkeeper conversation. In this case, you could use:
- Dialogue Text: Hi, I'm [var=Conversant]! Welcome to my shop!
You can do more sophisticated stuff with the [lua(
code)] tag, but it basically works the same way. Instead of providing a variable name, you provide a Lua expression. There's a good example in the documentation section for the
RandomElement() Lua function.
Re: Dialogue Text Help
Posted: Tue Oct 13, 2015 1:52 pm
by EWalk13
Just tried it and it worked out great thanks!
Re: Dialogue Text Help
Posted: Tue Oct 13, 2015 1:54 pm
by Tony Li
Wow, you're fast!
Re: Dialogue Text Help
Posted: Tue Oct 13, 2015 2:41 pm
by EWalk13
Haha I just happened to be working on my project with this when I saw your reply come up