Lua vs C#

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Hyrad
Posts: 26
Joined: Fri Jan 13, 2017 5:11 pm

Lua vs C#

Post by Hyrad »

Hello, I don't know much about lua but I am proficient with C# and object oriented programming. I see that you have extended support for Lua. Would there be any specific advantages to using it that would justify the extra time investment to learn the language vs working with C sharp?

Thanks,
-Jeff
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua vs C#

Post by Tony Li »

Hi Jeff,

Nope. Just use C#.

Some background info: The Dialogue System borrows its design from a professional dialogue authoring program called Chat Mapper. In fact, you can seamlessly import and export back and forth between the two, which a lot of studios do. Anyway, Chat Mapper uses Lua, which is one of the reasons why the Dialogue System has to. But Lua is also a language that a lot of modders are already familiar with, and the Dialogue System supports importing content at runtime, such as mods. (As a side note, since Lua is designed for modders, it's a much, much simpler language to learn than C#.)

When you're writing conversations, each dialogue entry node has a Script field and a Conditions field. These use Lua. Most people use the point-and-click Lua wizards (the "..." button) to automatically generate whatever Lua code they want to include in these fields, such as checking or setting a quest state.

However, it's quite easy to register your own C# code as a Lua function. Then just use that Lua function name in the Script or Conditions field to run your C# code. (This is what the third party integrations do.)
Hyrad
Posts: 26
Joined: Fri Jan 13, 2017 5:11 pm

Re: Lua vs C#

Post by Hyrad »

Thanks Tony for taking the time to explain, it puts things into perspective. I will be registering my own C# code as Lua functions, as per the manual link you provided ;)
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Lua vs C#

Post by Tony Li »

Sounds good!
Post Reply