Here's an example: Let's say your skill tree is in a script named SkillTree.cs that's on a GameObject named PlayerSkills:Is there any way to access conditions with C#instead of lua ??
...how can I get the value of an array through it ?
I've got a skill tree (which is an array) : I need to check the int of the the first element (my array is in another gameobject).
How can I do that through the RegisterFunction ?
Code: Select all
public class SkillTree : MonoBehaviour {
public int[] skills;
}
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class SkullLuaFunctions : MonoBehaviour {
void OnEnable() {
Lua.RegisterFunction("GetSkillValue", this, typeof(SkillLuaFunctions).GetMethod("GetSkillValue"));
}
void OnDisable() {
Lua.UnregisterFunction("GetSkillValue");
}
public double GetSkillValue(string gameObjectName, double arrayIndex) {
var go = GameObject.Find(gameObjectName);
if (go != null) {
var skillTree = go.GetComponent<SkillTree>();
if (skillTree != null) {
return skillTree.skills[(int) arrayIndex];
}
}
Debug.LogError("Can't find SkillTree script on GameObject " + gameObjectName);
return 0;
}
}
If you want to check if a skill value is greater than 5 in a conversation, set the Conditions field to:
Code: Select all
GetSkillValue("PlayerSkills", 0) > 5
If you need further help, please feel free to reply to this post or send an example project to tony (at) pixelcrushers.com.