using UnityEngine;
using PixelCrushers.DialogueSystem;
using TMPro;
using UnityEngine.UI;
public class PlayerStats : MonoBehaviour // Rename this class.
{
public int strenght = 15;
public int intelligence = 15;
public int MartialArts = 15;
public int energy = 100;
[SerializeField] TextMeshProUGUI strenghtvalue;
[SerializeField] TextMeshProUGUI intelligencevaulue;
[SerializeField] TextMeshProUGUI martialArtsvalue;
[SerializeField] TextMeshProUGUI energyvalue;
private void Update()
{
strenghtvalue.text = strenght.ToString();
intelligencevaulue.text = intelligence.ToString();
martialArtsvalue.text = MartialArts.ToString();
energyvalue.text = energy.ToString();
}
public void GiveStrenght(double amount)
{
strenght += (int)amount;
}
public void GiveIntelligence(double amount)
{
intelligence += (int)amount;
}
public void GiveMartialArts(double amount)
{
MartialArts += (int)amount;
}
public void GiveEnery(double amount)
{
energy += (int)amount;
}
void OnEnable()
{
Lua.RegisterFunction("GiveStrenght", this, SymbolExtensions.GetMethodInfo(() => GiveStrenght((double)0)));
Lua.RegisterFunction("GiveIntelligence", this, SymbolExtensions.GetMethodInfo(() => GiveIntelligence((double)0)));
Lua.RegisterFunction("GiveMartialArts", this, SymbolExtensions.GetMethodInfo(() => GiveMartialArts((double)0)));
Lua.RegisterFunction("GiveEnergy", this, SymbolExtensions.GetMethodInfo(() => GiveEnery((double)0)));
}
}
The script is attached to the dialogue manager.
The problem is that I can't add these functions. I created a New Custom Lua Function and added them like shown in the tutorial video. But when i click on conditions on the specific dialogue node nothing show up under custom.
You added the functions to the Script Functions section of your Custom Lua Function Info asset, which is correct.
But you're opening the Conditions field's dropdown, which will only show Condition Functions. Click Revert to Cancel that. Then click the Script field's "..." button.
I want the player only to be able to increase the intelligence up to 30. So I wrote a small method which checks the intelligence and sets the boolean variable IntelligenceunderThirty to false when the intelligence is 30 or higher.
using UnityEngine;
using PixelCrushers.DialogueSystem;
using TMPro;
using UnityEngine.UI;
public class PlayerStats : MonoBehaviour // Rename this class.
{
public int strenght = 15;
public int intelligence = 15;
public int MartialArts = 15;
public int energy = 100;
[SerializeField] TextMeshProUGUI strenghtvalue;
[SerializeField] TextMeshProUGUI intelligencevaulue;
[SerializeField] TextMeshProUGUI martialArtsvalue;
[SerializeField] TextMeshProUGUI energyvalue;
public bool intelligenceunderThirty;
private void Update()
{
strenghtvalue.text = strenght.ToString();
intelligencevaulue.text = intelligence.ToString();
martialArtsvalue.text = MartialArts.ToString();
energyvalue.text = energy.ToString();
Intelligenceunderthirty();
}
public void Intelligenceunderthirty()
{
if (intelligence < 30)
{
intelligenceunderThirty = true;
}
else
{
intelligenceunderThirty = false;
}
}
using UnityEngine;
using PixelCrushers.DialogueSystem;
using TMPro;
using UnityEngine.UI;
public class PlayerStats : MonoBehaviour // Rename this class.
{
public int strenght = 15;
public int intelligence = 15;
public int MartialArts = 15;
public int energy = 100;
[SerializeField] TextMeshProUGUI strenghtvalue;
[SerializeField] TextMeshProUGUI intelligencevaulue;
[SerializeField] TextMeshProUGUI martialArtsvalue;
[SerializeField] TextMeshProUGUI energyvalue;
public bool intelligenceunderThirty;
private void Update()
{
strenghtvalue.text = strenght.ToString();
intelligencevaulue.text = intelligence.ToString();
martialArtsvalue.text = MartialArts.ToString();
energyvalue.text = energy.ToString();
}
bool IsIntelligenceUnder30() { return intelligence < 30; }
public void GiveStrenght(double amount)
{
strenght += (int)amount;
}
public void GiveIntelligence(double amount)
{
intelligence += (int)amount;
}
public void GiveMartialArts(double amount)
{
MartialArts += (int)amount;
}
public void GiveEnery(double amount)
{
energy += (int)amount;
}
void OnEnable()
{
Lua.RegisterFunction("GiveStrenght", this, SymbolExtensions.GetMethodInfo(() => GiveStrenght((double)0)));
Lua.RegisterFunction("GiveIntelligence", this, SymbolExtensions.GetMethodInfo(() => GiveIntelligence((double)0)));
Lua.RegisterFunction("GiveMartialArts", this, SymbolExtensions.GetMethodInfo(() => GiveMartialArts((double)0)));
Lua.RegisterFunction("GiveEnergy", this, SymbolExtensions.GetMethodInfo(() => GiveEnery((double)0)));
Lua.RegisterFunction("IsIntelligenceUnder30", this, SymbolExtensions.GetMethodInfo(() => IsIntelligenceUnder30()));
}
}
I think it has something to do how I register the function under New Custom Lua Function. I register the Element 0 as a Bool because I don't have to enter a string or number like in the tutorial example.
In your Custom Lua Function Info, remove the Bool element from IsIntelligenceUnder30's Parameters list. IsIntelligenceUnder30() doesn't accept any parameters.