How to insert a new field to Variable table from LuaConsole?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Devrim
Posts: 1
Joined: Fri Jan 13, 2017 7:46 am

How to insert a new field to Variable table from LuaConsole?

Post by Devrim »

Hey Guys;

First of all thank you very much for your great product. It did took a lot of weight out of our shoulders.

Here is a point i could not succeeded to proceed. I would like our designers to be able to insert a field to Variable table from the console. I am not very familiar with the Lua syntax but tried this one from the LuaConsole at runtime:

Code: Select all

Variable.insert({name="test_var", initial_value="0", description="hello new var"})
but get an exception such as:
threw exception 'Invoke function call on non function value.'


What is the right point to achieve this?

Thank you.
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to insert a new field to Variable table from LuaConsole?

Post by Tony Li »

Hi,

Thanks; I'm glad your team is finding the Dialogue System to be helpful!

Try this to add a variable named "test_var" to the Variable table and give it a numeric value of 0:

Code: Select all

Variable["test_var"] = 0
If possible, store only primitive values (string, Booleans, and numbers) in the Variable table. The Dialogue System assumes the Variable table contains primitives, although technically you can store whatever you want in them. You might just get weird results in some edge circumstances if you're not using primitives.

When the Dialogue System initially populates the Variable table, it only uses the Name and Initial Value fields from the dialogue database. To see what it's doing internally, temporarily set the Dialogue Manager's Debug Level to Info. This will show the Lua commands it's running to populate Lua.

The other Dialogue System-managed tables (e.g., Actor, Item/Quest, Location) are two-dimensional. Each element points to a sub-table. You can add them like this:

Code: Select all

Actor["test_actor"] = { Name="Test Actor", Age=21, IsPlayer=false }
Post Reply