Hi,
Is there anyway to reset a variable to its initial value ? Initial value for my variable is "" and I am not able to set that variable again
Thanks.
Nishant
Reset Variable to Initial value that is nil or ""
Re: Reset Variable to Initial value that is nil or ""
Hi,
Can you just set it to "" in a dialogue entry's Script field?
If you don't know the initial value, you can get it from the dialogue database:
Can you just set it to "" in a dialogue entry's Script field?
- Script: Variable["MyVariable"] = ""
Code: Select all
DialogueLua.SetVariable("MyVariable", string.Empty);
Code: Select all
var initialValue = DialogueManager.MasterDatabase.GetVariable("MyVariable").InitialValue;
DialogueLua.SetVariable("MyVariable", initialValue);
Re: Reset Variable to Initial value that is nil or ""
Ok I did that , but there seems to another issue
The sequence of nodes is as follows
1. "Whats your name " - has condition display textbox only if PlayerName is "" which is the initial value and False condition is PassThrough
2. "Is your name [enteredName] " - it is followed by yes and no options
3. yes - moves on to next dialogue
4. no - resets the name and moves to 1st link
So Issue is name does reset but by the time I reach to node 1 , it seems the change isnt reflected while evaluating the condition. So as condition is termed as false , it passes that node and moves to node 2. Here we get "Is your name " as dialogue text . No if I again click No that time Textbox will appear.
How can I fix this ??
Thanks.
Nishant
The sequence of nodes is as follows
1. "Whats your name " - has condition display textbox only if PlayerName is "" which is the initial value and False condition is PassThrough
2. "Is your name [enteredName] " - it is followed by yes and no options
3. yes - moves on to next dialogue
4. no - resets the name and moves to 1st link
So Issue is name does reset but by the time I reach to node 1 , it seems the change isnt reflected while evaluating the condition. So as condition is termed as false , it passes that node and moves to node 2. Here we get "Is your name " as dialogue text . No if I again click No that time Textbox will appear.
How can I fix this ??
Thanks.
Nishant
Re: Reset Variable to Initial value that is nil or ""
Hi Nishant,
Check this example: Nishant_2015-10-07.unitypackage
Add a "spacer" node. The Dialogue System always evaluates one level ahead. This allows it to know what the follow-up nodes are. It needs to know this to know whether to play another NPC line or show the response menu. In the screenshot below, the spacer node is called "(empty hub)":
The "(empty hub)" node's Sequence is: None() so it immediately evaluates it and moves to the next step in the conversation. The spacer node delays evaluation of the "What's your name?" node.
If the player answers "No," the response's Script resets the PlayerName variable, and the node links back to the top.
Check this example: Nishant_2015-10-07.unitypackage
Add a "spacer" node. The Dialogue System always evaluates one level ahead. This allows it to know what the follow-up nodes are. It needs to know this to know whether to play another NPC line or show the response menu. In the screenshot below, the spacer node is called "(empty hub)":
The "(empty hub)" node's Sequence is: None() so it immediately evaluates it and moves to the next step in the conversation. The spacer node delays evaluation of the "What's your name?" node.
If the player answers "No," the response's Script resets the PlayerName variable, and the node links back to the top.
- Script:Variable["PlayerName"] = ""
Re: Reset Variable to Initial value that is nil or ""
Perfect thats exactly what was need .. thanks
Re: Reset Variable to Initial value that is nil or ""
Great! Happy to help.