Does Dialogue System Have Support For Loading .lua files?
-
- Posts: 2
- Joined: Wed Mar 10, 2021 8:07 am
Does Dialogue System Have Support For Loading .lua files?
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?
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():
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.
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);
-
- Posts: 2
- Joined: Wed Mar 10, 2021 8:07 am
Re: Does Dialogue System Have Support For Loading .lua files?
Ah very interesting! Thanks!