Hey GiL, i'm pretty terrible at scripting, so please bare with me.
I'm making the bestiary list, with a premade layout of each combatant so that I can display unknown monsters.

Button name needs to change from something like "----" to CombatantName

I see in the API there is a IsKnown() function and a GetName() one

I'm assuming I need to pass a GUID as an argument into each function - or do i need to pass something else?

Can you advise how i access these? Is it BestiaryLearnSetting.IsKnown(GUID) and BestiaryEntry.GetName(GUID)?

Since the Bestiary is part of the menu, i'm guessing it uses donotdestroy, so i will need to update the button names in OnEnable() or will I be able to do it in OnStart()

example of what i'm thinking:



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;
}
}
}


Post edited by fourscoopsplease on
  • Yeah, there's not much correct here ... you try to create a new bestiary entry with a static property that doesn't exist, bestiary settings is never initialized, etc.

    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.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.