Hello!
I'm having a blast getting the dialogue system up and running for my game, but I'm having a lot of trouble trying to figure out how to execute multiple scripts when a dialogue choice is made.
I have an animation function that makes the character leave the screen after the dialogue ends, so I used a sendMessage function to call my "CharacterLeave()" function from the message sequence section on the inspector of every "END" node. Not sure exactly how that works, but it works.
Now I'm trying to make it so certain dialogue choices give + or - gold, faction points etc. How do I do this correctly?
I tried putting in multiple sendMessage lines separated by semicolons, but that doesn't seem to work.
Thank you!
Executing multiple functions after a dialogue choice is made
Re: Executing multiple functions after a dialogue choice is made
Hi,
You can put multiple commands -- even multiple SendMessage() commands -- in a node's Sequence field, such as:
However, SendMessage can only call C# methods that have no parameters or a single string parameter. If you have a C# method ModifyGold(int amount), then I recommend registering it with Lua (tutorial) and calling it in the node's Script field. Alternatively, you can write a custom sequencer command if you want to keep everything in the Sequence field, but I prefer to use the Sequence field for things the player directly experiences (such as animation, audio, and camerawork) and the Script field for data handling (such as incrementing gold and faction values).
You can put multiple commands -- even multiple SendMessage() commands -- in a node's Sequence field, such as:
Code: Select all
SendMessage(CharacterLeave, , speaker); // Call CharacterLeave() on the speaker.
SendMessage(Footsteps, , speaker); // Call Footsteps() on the speaker.
LiveCamera(Wide, speaker, 2); // Do a wide camera follow on the speaker.
Re: Executing multiple functions after a dialogue choice is made
Thank you for the quick reply!
This is a lot simpler than I thought it would be.
You're helping us tell stories!
This is a lot simpler than I thought it would be.
You're helping us tell stories!
Re: Executing multiple functions after a dialogue choice is made
Happy I could help!