Problem with registering variables/functions
Posted: Sun Apr 23, 2023 1:41 pm
Hi,
so I am developing an adventure game where you have several stats which should increase after certain conversations.
I read up and watched the tutorial about registering variables and accustomed the template accordingly.
The code looks something like this:
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.
https://ibb.co/wdj1t2N
https://ibb.co/qgtwyJ3
Thanks
so I am developing an adventure game where you have several stats which should increase after certain conversations.
I read up and watched the tutorial about registering variables and accustomed the template accordingly.
The code looks something like this:
Code: Select all
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 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.
https://ibb.co/wdj1t2N
https://ibb.co/qgtwyJ3
Thanks