[SOLVED]How output variable value in Dialogue text field?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Evgeny
Posts: 16
Joined: Sun Mar 13, 2016 11:18 am

[SOLVED]How output variable value in Dialogue text field?

Post by Evgeny »

Two small questions.

1. How output Lua variable name and value in Dialogue text field?

2. On what event it is possible to make something for certain Dialogue Entry ID? Something like OnConversationStart.
For an example to receive a variable from C#, to process it in Lua and to return back to C#.
Last edited by Evgeny on Fri Apr 08, 2016 12:59 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: How output variable value in Dialogue text field?

Post by Tony Li »

Hi,
Evgeny wrote:1. How output Lua variable name and value in Dialogue text field?
For a Dialogue System variable -- that is, defined on the Variables tab of the Dialogue Editor and as Variable["varName"] in Lua -- use the [var=varName] markup tag:
  • Dialogue Text: "Hi, my name is [var=Conversant]."
For general Lua expressions, use the [lua(code)] markup tag:
  • Dialogue Text: "Next year I will be [lua( Actor["Fred"].Age + 1 )] years old."
Evgeny wrote:2. On what event it is possible to make something for certain Dialogue Entry ID? Something like OnConversationStart.
For an example to receive a variable from C#, to process it in Lua and to return back to C#.
Register your C# function with Lua. Then you can use it anywhere in Lua, such as the Dialogue Text or Script fields of your dialogue entry. For example:
  • Dialogue Text: "Take this gold."
  • Script: GivePlayerGold(50)

Code: Select all

Lua.RegisterFunction("GivePlayerGold", this, typeof(MyLuaFunctions).GetMethod("GivePlayerGold"));
        
public void GivePlayerGold(double amount) {
    playerInventory.gold += (int) amount;
} 
Another way is to add a script that has an OnConversationLine method.
Evgeny
Posts: 16
Joined: Sun Mar 13, 2016 11:18 am

Re: [SOLVED]How output variable value in Dialogue text field?

Post by Evgeny »

BiG ThNX!! :)

All works fine! :)
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: [SOLVED]How output variable value in Dialogue text field?

Post by Tony Li »

Great! Glad I could help.
Post Reply