Page 1 of 1

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

Posted: Fri Apr 08, 2016 8:06 am
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#.

Re: How output variable value in Dialogue text field?

Posted: Fri Apr 08, 2016 9:16 am
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.

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

Posted: Fri Apr 08, 2016 12:59 pm
by Evgeny
BiG ThNX!! :)

All works fine! :)

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

Posted: Fri Apr 08, 2016 1:06 pm
by Tony Li
Great! Glad I could help.