If Click Node Then
Re: If Click Node Then
Happy to help! If you have any questions about using or extending the example, just let me know.
Re: If Click Node Then
Hi Tony! I've been working with your Dialog system for a few months now. This was almost exactly what I was looking for!
I need to check to see if a player has a specific variable set to a certain value (ie if they have a certain skill) to allow a dialog node to appear. How would I check a value in the condition field? I'm assuming it would be similar to this thread, except using the condition field instead of the script field?
I need to check to see if a player has a specific variable set to a certain value (ie if they have a certain skill) to allow a dialog node to appear. How would I check a value in the condition field? I'm assuming it would be similar to this thread, except using the condition field instead of the script field?
Re: If Click Node Then
Yes, that's it exactly. An earlier post in this thread has an example with two Lua functions: SetMoney() and GetMoney(). You can use GetMoney() in the Conditions field to check if the player has enough money:
- Dialogue Text: "Sorry, you don't have enough money."
Conditions: GetMoney() < 100 - Dialogue Text: "I see you have enough money. Want to buy this?"
Conditions: GetMoney() >= 100
Re: If Click Node Then
I see how it's supposed to work now. Thanks a bunch!
Re: If Click Node Then
ok, so I guess this is more complicated than I thought. Here is the scenario:
* Player has a certain amount of skills that can be promoted
* different NPCs teach different skills
* I need to check to see if the player has the same skill that the NPC teaches
The issue that I've been having is that multiple NPCs are registering the same LUA function and (I think) Lua is calling the wrong one.
Is that the case? I'm assuming that LUA isn't smart enough to know to call the function attached to the dialog's game object?
* Player has a certain amount of skills that can be promoted
* different NPCs teach different skills
* I need to check to see if the player has the same skill that the NPC teaches
The issue that I've been having is that multiple NPCs are registering the same LUA function and (I think) Lua is calling the wrong one.
Is that the case? I'm assuming that LUA isn't smart enough to know to call the function attached to the dialog's game object?
Re: If Click Node Then
It's a global Lua environment, not specific to each NPC.
There are a few ways you could handle this. Choose the one you prefer.
1. Add a different Lua function for each NPC or each skill. For example, add Lua functions such as:
2. Or pass the skill name as a string. So your Lua function might look like:
and you'd use it like this:
3. Or look at the value of an actor's custom field. For example, expand Wyld the Warrior's All Fields section, and add a custom field named "Skill Type" set to "Warrior". Then register Lua functions named GetNPCSkill() and SetNPCSkill(#) that check the current conversant's
and you'd use it like this:
There are a few ways you could handle this. Choose the one you prefer.
1. Add a different Lua function for each NPC or each skill. For example, add Lua functions such as:
- GetWarriorSkill()
- SetWarriorSkill()
- GetMageSkill()
- SetMageSkill(), etc.
- Dialogue Text: "I'm Wyld the Warrior. Want to learn level 2 warrior skills?"
Conditions: GetWarriorSkill() < 2
2. Or pass the skill name as a string. So your Lua function might look like:
Code: Select all
double GetSkillLevel(string skillName) {
return // (skill level of skill named by skillName)
}
- Dialogue Text: "I'm Wyld the Warrior. Want to learn level 2 warrior skills?"
Conditions: GetSkillLevel("Warrior") < 2
3. Or look at the value of an actor's custom field. For example, expand Wyld the Warrior's All Fields section, and add a custom field named "Skill Type" set to "Warrior". Then register Lua functions named GetNPCSkill() and SetNPCSkill(#) that check the current conversant's
Code: Select all
double GetNPCSkill() {
string npcName = DialogueLua.GetVariable("ConversantIndex");
string npcSkillName = DialogueLua.GetActorField(npcName, "Skill Type").AsString;
return // (skill level of skill named by npcSkillName)
}
- Dialogue Text: "I'm Wyld the Warrior. Want to learn level 2 warrior skills?"
Conditions: GetNPCSkill() < 2
Re: If Click Node Then
Thanks for the help Tony! You rule.
all are great options, but I think passing the variable is the best idea. How many vars can you pass from Lua?
all are great options, but I think passing the variable is the best idea. How many vars can you pass from Lua?
Re: If Click Node Then
Like C#, you can pass as many as you want. For example, you could define a function "IsLevelMet" that accepts three parameters: class name, skill name, and minimum level:
- Dialogue Text: "I see you are a master conjurer. Do you do birthday parties?"
Conditions: IsLevelMet("Wizard", "Conjuration", 15)
Code: Select all
bool IsLevelMet(string className, string skillName, double minLevel) {
...
}
Re: If Click Node Then
Thanks Tony! I've got it all sorted now.
Re: If Click Node Then
Great! Glad to help.