I'm making a game like DDLC or Homestuck Friendsim, and I want to have different branching dialogue paths, and I'm not sure how to do this optimally. The way I'm doing it, each piece of dialogue is in a list along with attributes for the text engine to render and if there is a choice to be made after its done typing, there is another item in the list that gives the options, and it brings up a menu showing those options. I really want to avoid creating something like how Undertale handled dialogue, but I have absolutely no idea what I'm doing.
By using case/switch? There's literally nothing wrong with that
i think the best way to do this (besides using switch and case like owlssssnap said) is to use this:
it's a reliable way, though the code can get a bit long depending on how deep the dialogue goes
This is arguably worse because Snap! has to process each if block individually instead of all at once, which adds a delay.
But I suppose Snap also doesn't have a native switch/case block like other programming languages either so this works fine
It sounds like what you're talking about is a finite state machine, which just means what it sounds like: at any time, the program is in a particular state, which is just an abstract data structure, and each state has possible transitions to other states. So your game data will look something like this:
This isn't really finished, because you want a way to give multi-word commands like "open door" or "take sword" and so on (and for the latter you'll need to have a global possessions variable, etc.).