If Click Node Then
If Click Node Then
Hello I have done the tutorial Quickstart.
Now i have many Nodes.
My question is the following:
How can I react to the single clicked node
for example
NPC: "Hallo how are you"
Player Answer A: "Thx i'm fine"
Player Answer B: "Very bad"
if Answer A then{ dosomethingA}
For Example: Player.setMoney += 300;
if Answer B then {dosomethingB}
For Example: "Game Over"
A small example would be perfect
Excuse me for the basic questions, but somehow the documentation is so great. I do not see the forest in front of loud trees.
Thank you very much
Now i have many Nodes.
My question is the following:
How can I react to the single clicked node
for example
NPC: "Hallo how are you"
Player Answer A: "Thx i'm fine"
Player Answer B: "Very bad"
if Answer A then{ dosomethingA}
For Example: Player.setMoney += 300;
if Answer B then {dosomethingB}
For Example: "Game Over"
A small example would be perfect
Excuse me for the basic questions, but somehow the documentation is so great. I do not see the forest in front of loud trees.
Thank you very much
Re: If Click Node Then
Hi,
Every dialogue entry node has three types of "control" fields: Conditions, Script, and Sequence.
Conditions field:
You can use the Conditions field to make a dialogue entry node available or not available. For example*:
Script field:
You can use the Script field to add actions to a dialogue entry node, such as giving money. For example*:
To work with Dialogue System data, such as variables you've defined in the Variables section of the Dialogue Editor, you don't have to type anything. You can use the point-and-click Lua Wizards.
On the other hand, if you want Lua to reach outside of the Dialogue System to your own scripts, you can register your C# methods with Lua. This is what the third party integration packages do. For example, the Opsive Third Person Controller integration registers Lua functions to set the player's health, give or take items, etc.
If "Player.money" is a value in your own script, register a C# method with Lua so you can access it in the Script field.
Sequence field:
The Sequence field lets you run a cutscene sequence.
The Conditions and Script fields are mostly for data (e.g., check and change variable values). The Sequence field, on the other hand, is for changing what the player experiences -- for example, zooming the camera, or playing audio clips. The Dialogue System comes with a big library of built-in sequencer commands. However, you can also write your own custom sequencer commands. The example provided in the documentation adds a LoadLevel sequencer command that you can use to load a new scene during a conversation.
Every dialogue entry node has three types of "control" fields: Conditions, Script, and Sequence.
Conditions field:
You can use the Conditions field to make a dialogue entry node available or not available. For example*:
- NPC: "Hallo how are you"
- Player Answer A: "Thx i'm fine"
- Player Answer B: "Very bad"
- Player Answer C: "I'm rich!"
Conditions: Player.money > 1000
Script field:
You can use the Script field to add actions to a dialogue entry node, such as giving money. For example*:
- NPC: "Hallo how are you"
- Player Answer A: "Thx i'm fine"
Script: Player.money += 300; - Player Answer B: "Very bad"
Script: Game over
- Player Answer A: "Thx i'm fine"
To work with Dialogue System data, such as variables you've defined in the Variables section of the Dialogue Editor, you don't have to type anything. You can use the point-and-click Lua Wizards.
On the other hand, if you want Lua to reach outside of the Dialogue System to your own scripts, you can register your C# methods with Lua. This is what the third party integration packages do. For example, the Opsive Third Person Controller integration registers Lua functions to set the player's health, give or take items, etc.
If "Player.money" is a value in your own script, register a C# method with Lua so you can access it in the Script field.
Sequence field:
The Sequence field lets you run a cutscene sequence.
The Conditions and Script fields are mostly for data (e.g., check and change variable values). The Sequence field, on the other hand, is for changing what the player experiences -- for example, zooming the camera, or playing audio clips. The Dialogue System comes with a big library of built-in sequencer commands. However, you can also write your own custom sequencer commands. The example provided in the documentation adds a LoadLevel sequencer command that you can use to load a new scene during a conversation.
Re: If Click Node Then
sry i dont Really understand?
"On the other hand, if you want Lua to reach outside of the Dialogue System to your own scripts, you can register your C# methods with Lua. This is what the third party integration packages do. For example, the Opsive Third Person Controller integration registers Lua functions to set the player's health, give or take items, etc."
Im must buy this??:Opsive Third Person Controller
So I can realize my idea ??
"On the other hand, if you want Lua to reach outside of the Dialogue System to your own scripts, you can register your C# methods with Lua. This is what the third party integration packages do. For example, the Opsive Third Person Controller integration registers Lua functions to set the player's health, give or take items, etc."
Im must buy this??:Opsive Third Person Controller
So I can realize my idea ??
Re: If Click Node Then
No. You do not have to buy anything else.
I'm sorry I was unclear. Let's restart the discussion from the beginning.
You wrote this:
I'm sorry I was unclear. Let's restart the discussion from the beginning.
You wrote this:
What is "Player.setMoney"? Where does it come from?Barto1983 wrote:if Answer A then{ dosomethingA}
For Example: Player.setMoney += 300;
Re: If Click Node Then
public static class Player {
public static int money = 300;
}
it a normal static c# class
if Answer A then{ dosomethingA}
For Example: Player.money += 300;
I will add 300 to Player.money if the Answer is A
or Change Background Image or Close Game and so on
I search something like OnNodeEventClick(){
}
public static int money = 300;
}
it a normal static c# class
if Answer A then{ dosomethingA}
For Example: Player.money += 300;
I will add 300 to Player.money if the Answer is A
or Change Background Image or Close Game and so on
I search something like OnNodeEventClick(){
}
- Attachments
-
- Conv.PNG (55.07 KiB) Viewed 1414 times
Re: If Click Node Then
Hi,
I'm going to be out of the office for a couple hours, but I'll send you an easy to follow example as soon as I get back.
I'm going to be out of the office for a couple hours, but I'll send you an easy to follow example as soon as I get back.
Re: If Click Node Then
Here's an example scene: CustomLuaExample_2017-03-02.unitypackage
It's just like your conversation, except the "oh no" dialogue entry node's Script contains this:
It uses functions "GetMoney" and "SetMoney". A new script PlayerLua.cs adds these functions. I added PlayerLua.cs to the Dialogue Manager.
PlayerLua.cs
It's just like your conversation, except the "oh no" dialogue entry node's Script contains this:
Code: Select all
SetMoney(50 + GetMoney())
PlayerLua.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class PlayerLua : MonoBehaviour {
void OnEnable() {
Lua.RegisterFunction("GetMoney", this, GetType().GetMethod("GetMoney"));
Lua.RegisterFunction("SetMoney", this, GetType().GetMethod("SetMoney"));
}
void OnDisable() {
Lua.UnregisterFunction("GetMoney");
Lua.UnregisterFunction("SetMoney");
}
public double GetMoney() {
return Player.money;
}
public void SetMoney(double amount) {
Player.money = (int)amount;
}
}
Re: If Click Node Then
Hey thx you for you fast answer.
I will try it when iam at home.
Thx
I will try it when iam at home.
Thx
Re: If Click Node Then
Hi Tony Li I would like to thank you for the quick help.
That's what I call a great support.
Keep up the good work
That's what I call a great support.
Keep up the good work