Hi there,
I've poured over the documentation and I still can't make heads or tails of how variables work in this system.
Can you give me some simple details on the following scenario please.
We have a character.
We have a variable called foo, it is a bool and its initial value is false.
The character has one conversation, it has a start then two child nodes. One has dialogue text "This way" the other has dialogue "That way".
The behavior I want is that the first time that conversation takes place, the character says "This way" and foo gets set to true.
The next time the character is interacted with they say "That way" and foo gets set to false again.
Can you give me the exact syntax I would use in the conditions field for this scenario please?
Thanks,
Confused about variables
Re: Confused about variables
Hi,
Here are the steps I'd use:
1. In the Dialogue Editor, go to the Variables tab. Using the Menu dropdown in the upper right, add a new variable.
2. Expand this variable's foldout. Change the Name to foo. Change the Type to Boolean.
3. On the Conversations tab, create a new conversation. Right click on START and select Add Child Node. Repeat so START has two child nodes. Then set their Dialogue Text fields to "This way" and "That way".
4. Inspect the "This way" node. Click the "..." button to the right of the Conditions field. This will open the Lua wizard.
5. In the Lua wizard section, click the "+" button in the lower left. This will add a dropdown row.
6. In the dropdown row, select the following dropdown values: Variable > foo > Is > False. Then click Apply. The Lua wizard will disappear, and the Conditions field will be:
7. Now click the "..." button to the right of the Script field. This will open another Lua wizard.
8. In the Lua wizard section, click the "+" button to add a dropdown row.
9. In the dropdown row, select these values: Set Variable > foo > to > True. Then click Apply. The Script field will be:
10. Now inspect the "That way" node. Click the "..." button to the right of Conditions. Click "+", and set the dropdown row to Variable > foo > Is > True. Then click Apply. The Conditions field will be:
If you don't want to use the Lua wizards, or if you're using a third party editor such as Chat Mapper or articy:draft, you can enter the Lua code manually. If you do this, it will help to review the short Lua Syntax Gotchas section.
If you want to debug a conversation, temporarily set the Dialogue Manager's Debug Level to Info. This will log a lot of activity to the Console so you can see what's going on under the hood.
During play, you can inspect a conversation in the Dialogue Editor to see which line is currently playing, and which links are true or false. Also, the Templates tab changes to a Watch tab where you can set watches on variables and expressions. Finally, you can add a Lua Console component to the scene. Press ~+L to open the console, where you can enter Lua commands such as:
Here are the steps I'd use:
1. In the Dialogue Editor, go to the Variables tab. Using the Menu dropdown in the upper right, add a new variable.
2. Expand this variable's foldout. Change the Name to foo. Change the Type to Boolean.
3. On the Conversations tab, create a new conversation. Right click on START and select Add Child Node. Repeat so START has two child nodes. Then set their Dialogue Text fields to "This way" and "That way".
4. Inspect the "This way" node. Click the "..." button to the right of the Conditions field. This will open the Lua wizard.
5. In the Lua wizard section, click the "+" button in the lower left. This will add a dropdown row.
6. In the dropdown row, select the following dropdown values: Variable > foo > Is > False. Then click Apply. The Lua wizard will disappear, and the Conditions field will be:
Code: Select all
Variable["foo"] == false
8. In the Lua wizard section, click the "+" button to add a dropdown row.
9. In the dropdown row, select these values: Set Variable > foo > to > True. Then click Apply. The Script field will be:
Code: Select all
Variable["foo"] = true
Code: Select all
Variable["foo"] == true
If you want to debug a conversation, temporarily set the Dialogue Manager's Debug Level to Info. This will log a lot of activity to the Console so you can see what's going on under the hood.
During play, you can inspect a conversation in the Dialogue Editor to see which line is currently playing, and which links are true or false. Also, the Templates tab changes to a Watch tab where you can set watches on variables and expressions. Finally, you can add a Lua Console component to the scene. Press ~+L to open the console, where you can enter Lua commands such as:
Code: Select all
return Variable["foo"]
-
- Posts: 91
- Joined: Tue Jul 14, 2015 8:22 am
Re: Confused about variables
Thanks for the great response, that was exactly what I needed!
For future reference I was actually on the right track but my inspector was so small I couldn't see the apply or revert button! Might be worth moving those down if the window is too small.
For future reference I was actually on the right track but my inspector was so small I couldn't see the apply or revert button! Might be worth moving those down if the window is too small.
Re: Confused about variables
Good point about the inspector. The Lua wizards are getting a facelift soon, so I've added this to the list!