public class BestiaryButtonName : MonoBehaviour
{
public Button myButton;
public Text buttonText;
public int combatantGUID = 1;
private BestiaryEntry bestiaryEntry;
private BestiaryLearnSetting bestiarySetting;
void Start()
{
bestiaryEntry = BestiaryEntry.GetCombatant.ID(combatantGUID);
if (bestiaryEntry != null)
{
UpdateButtonName();
}
else
{
Debug.LogError("Bestiary entry not found for combatant ID: " + combatantGUID);
}
}
void UpdateButtonName()
{
if (bestiarySetting.IsKnown())
{
buttonText.text = bestiaryEntry.GetName();
myButton.interactable = true;
}
else
{
buttonText.text = "------";
myButton.interactable = false;
}
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
You can access the game's bestiary via ORK.Game.Bestiary - e.g. to check if a combatant is known or get entries for a combatant. I'd recommend to create a dummy combatant instance for each of your buttons, see this documentation for details on creating combatants via script.
That way you can check if the combatant is known and change the button text based on that (you can get the name of the combatant from the combatant directly).
So, in your Start function create the combatant (with default start level, etc., see the linked documentation for details on creating one with other setup):
Combatant combatant = ORK.Access.Combatant.CreateInstance(ORK.Game.Combatants.Get(index), new Group(), false, false);
In the button update, just check if the combatant is known:
if(ORK.Game.Bestiary.IsKnown(combatant))
And use the combatant's name instead of bestiary entry.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!