Page 1 of 1

Does Dialogue System Have Support For Loading .lua files?

Posted: Sat Apr 24, 2021 4:41 am
by Soulessvagabond
So I know that LUA is used for Dialogue System for Unity to handle conditions, variables and general control of the database at runtime. What I was wondering is does Dialogue System For Unity have an inbuilt ability to load/parse .lua files if I were to say set up lua functions within a file rather than linking C# methods through the tutorial listed in the docs?

Re: Does Dialogue System Have Support For Loading .lua files?

Posted: Sat Apr 24, 2021 8:11 am
by Tony Li
Hi,

There are two ways to do that.

You can put your Lua code in the Global User Script section of your dialogue database, which you can edit on the Database page of the Dialogue Editor window.

Or you can load the .lua file into a string and send it to Lua.Run():

Code: Select all

string luaCode = System.IO.File.ReadAllText("myfile.lua");
Lua.Run(luaCode);
The Dialogue System's Lua environment is sandboxed for safety, so it doesn't give direct access to the OS, including files. However, you can read files in your own C# scripts like the code above and then run that in Lua.

Re: Does Dialogue System Have Support For Loading .lua files?

Posted: Sat Apr 24, 2021 8:30 am
by Soulessvagabond
Ah very interesting! Thanks!

Re: Does Dialogue System Have Support For Loading .lua files?

Posted: Sat Apr 24, 2021 8:36 am
by Tony Li
Glad to help!