Should I just hardcode it like
if (i chose response #1 to the NPCs first dialogue) then
present second dialogue with response_option_A, response_option_B, response_option_C
if (i choose response_option_A) then
present third dialogue with Yes or No
if (person clicked yes)
do action 1
else
do action 2
if (i choose response_option_B) then
present fourth dialogue with "I see, so that's how it is" and "I don't get it, can you repeat that?"
if (i choose "I see, so that's how it is") then
move on
else
repeat text
elseif (i chose response #2 to the NPCs dialogue) then
present present third dialogue
elseif
... etc.
so one response leads to another, or is there a more efficient way of reusing code so I could make new NPCs with new dialogues super easily? i tried making this wack system using modulescripts with nested dictionaries, pairing each dialogue with a list of responses, but it didn’t work. How would you guys go about it?
Please feel free to share your thoughts.
Edit: Sorry, I think I somehow must have explained what I was asking for incorrectly, I edited the pseudocode above so it’s more specific now.
I’m looking for a dialogue system that the player can respond to, but there will be multiple different responses you can choose. for example, if an NPC speaking to me said:
“Do you have a sword?”
then there would be 3 responses
- Yes
- No
- I decline to say.
and whatever response you choose, another dialogue shows up. For example, if you choose “Yes” maybe the NPC will display “Oh, that’s great, I need you to defeat 3 goblins” and would give you 2 responses to that such as “Okay, I accept the mission” or “No, this sucks, count me out.” If you instead chose “No”, the NPC would say “Well, I need you to go get a sword” then he sends you on a mission to get a sword, and finally, if you choose “I decline to say”, the NPC would probably say “darn, you’re one boring kid, you know that?”
See how the dialogue branches out? one response leads to 3 more, and each of those 3 responses leads to 2 more responses, and maybe those responses lead to more. You get the point, right?