No code to show here, just general questions: I made a simple text parser using ink's integration plugin, nothing too fancy but working better than everything I tried, I want to expand on it a little bit by detecting custom functions(?), E.g: if there is [Player] replace it with the name of the player, if the text is [Speaker]John:[/Speaker] I am john then remove john from that string and set it as a separate string for the speaker.... what would be the best approach to achieve that? or what are the functions i should be looking at? Follow up to the previous question, what would be the best approach to handle all those functions. dictionaries? Speaking of dialogue, what would be the best approach to handling variables for dialogue, in other words, to keep track of what dialogues played and what didn't , what conditions are true and what conditions are not? the best thing i can think of would be 2 dictionaries, one with the condition variables one for the visited dialogues, make a serializable array of conditions and check them before playing the dialogue. I guess whatever the answer to that is would also apply to quests later on. Thanks a lot in advance.
posting this as a reply because it is longer and less important but I feel like my code could be cleaner than the mess i have right now, wanted to make the parser script reusable for all dialogue and have a reader script have all the parameters, but it ended up the other way around Code (CSharp): public class InkCustomParser : MonoBehaviour { // Compiled json asset Story _inkStory; bool firstExecution = true; [SerializeField] TextMeshProUGUI dialogueTextBox; [SerializeField] Button[] options; public void ReadStory(TextAsset textToRead) { if (firstExecution) { SetStoryToRead(textToRead); ContinueStory(); firstExecution = false; } if (_inkStory.currentChoices.Count > 0) { DisplayButtons(); } if (_inkStory.canContinue && Input.GetKeyUp(KeyCode.Return)) { ContinueStory(); } if (!_inkStory.canContinue && _inkStory.currentChoices.Count == 0 && Input.GetKeyUp(KeyCode.Return)) { EndOfStory(); } } private void DisplayButtons() { for (int choiceIndex = 0; choiceIndex < _inkStory.currentChoices.Count; ++choiceIndex) { Choice choice = _inkStory.currentChoices[choiceIndex]; options[choiceIndex].gameObject.SetActive(true); options[choiceIndex].GetComponentInChildren<TextMeshProUGUI>().text = choice.text; } } private void HideButtons() { for (int buttonIndex = 0; buttonIndex < options.Length; ++buttonIndex) { options[buttonIndex].gameObject.SetActive(false); } } private void ContinueStory() { dialogueTextBox.text = _inkStory.Continue(); } private void SetStoryToRead(TextAsset textToRead) { _inkStory = new Story(textToRead.text); } public void ChoosePath(int index) { Debug.Log("index is " + index); _inkStory.ChooseChoiceIndex(index); HideButtons(); ContinueStory(); } private void EndOfStory() { HideCanvas(); _inkStory = null; } private void HideCanvas() { gameObject.GetComponentInChildren<Canvas>().gameObject.SetActive(false); } } } below is the reader that was supposd to contain the parameters Code (CSharp): public class InkCustomReader : MonoBehaviour { [SerializeField] TextAsset dialogue; InkCustomParser dialogueParser; private bool dialoguePlayed = false; private void Awake() { if (dialogue == null) { Debug.Log("No Dialogue To read, script stopped from executing"); this.enabled = false; } } private void Start() { dialogueParser = FindObjectOfType<InkCustomParser>(); } private void Update() { if (!dialoguePlayed) { StartDialogue(dialogue); } } private void StartDialogue(TextAsset dialogue) { dialogueParser.ReadStory(dialogue); } }