How to hold a conversation with an NPC using Beastslash's Dialogue Maker

Creating a message

  1. Select your NPC’s model in the Workspace.

  1. Open the Dialogue Maker by pressing the Edit Dialogue button in the toolbar.

  1. Add a message by pressing the Add Dialogue button in the Dialogue Maker.

  1. Click inside of the empty text area and add a message for our friend to say!

  1. After typing a message, press the Enter key to save it!

If we were to play the game now and click our friend here, he would greet us with joy!

…But what if we wanted to make it more personal? We aren’t really friends if we don’t know each others’ names, so let’s fix that.

Setting message variables with actions

We could tell him our name by setting a message variable and embedding it in the message. Here’s how we can do it.

  1. Select the NPC model if it isn’t already selected.

  2. Open the Dialogue Maker if it isn’t already open.

  3. Click the circle under Ab (“Action before”). This should open a script named “Action”.

  1. Make Action.Variables return {PlayerName = Player.Name} rather than just {}.

  2. Exit the script, head back to the Dialogue Maker, and change our friend’s message text to “Good morning, [/variable=PlayerName]!”

  1. Press Enter to save it!

Now, if we were to head back to the game again to talk to our buddy, he’ll greet us along with saying our name!

Nice!

…But at the time I’m writing this tutorial, it’s actually 2:35 PM. So how do we make him recognize it’s actually the afternoon?

We use conditions.

Using conditions to prioritize messages

We can use conditions to make messages not appear if a criteria isn’t met. This will cause the NPC to say a message that has a lower priority!

Here’s how we can do it.

  1. Select the NPC model if it isn’t already selected.

  2. Open the Dialogue Maker if it isn’t already open.

  3. Click the circle under the ? (condition) button. This should open a script named “Condition”.

  1. Inside of the function, set the following code:
local Date = os.date("*t") -- Get the current date

if Date.hour <= 12 then
  return true -- It's the morning!
end

return false -- It's the afternoon!
  1. Exit the script and head back to the Dialogue Maker.

  2. Click the Add Dialogue button.

  3. Replace the second message’s text with "Good afternoon, [/variable=PlayerName!]"

“But wait,” I could hear someone say. “What about the variable we set in the first message? Would that carry to the second message?”

Good question! No, it won’t carry to the second message because that was an action that would be executed if the message was prioritized. Because the second message will be prioritized, we’ll need to set a new action.

  1. On the second message, click the circle under Ab.

  2. Make Action.Variables return {PlayerName = Player.Name}.

Easy fix! Now let’s check up on our friend.

Yes! He now knows that it’s the afternoon.

…But this isn’t really a conversation. Only one person is talking.

How about we change that?

Making the conversation interactive with responses

We can use responses to give the player options that can trigger new messages, redirect to messages on a different priority level, and run actions when they’re selected! For this tutorial, we’re only going trigger another message.

Here’s how we do it:

  1. Select the NPC model.

  2. Open the Dialogue Maker if it isn’t already open.

  3. Click View Children on the second message.

  1. Click Add Dialogue.

  2. Right-click the priority number of the new message. This should turn the message into a response, and turn its background green!

  1. Now, add some response text. How about “How’s your afternoon?”

  2. Press enter to save!

Great! We’ve added a response for the player to choose, but when the player clicks it, the dialogue box will close! This is because we haven’t set anything to happen if the player clicked it. Let’s change that.

  1. Click View Children on our new response.

  1. Click Add Dialogue.

  2. Edit the text for our buddy to say something when the player clicks that response!

Now, let’s check out what happens after we click our new response:

Awesome!

…But what if we come back to our game in the morning? No matter what, our buddy always has a good day, so we don’t have to do much to his response after we ask how he’s doing, however, our response has to change, as we, like him, know it’s not the morning.

As always, we have a solution.

Adding redirects

Redirects are a neat way for you to shift priorities. They’ll be helpful in our situation because our buddy doesn’t have to change his perfect lifestyle. So let’s get to it:

  1. Select the NPC model if you already didn’t.

  2. Open the Dialogue Maker if it isn’t already open.

  3. Go inside our first message’s children by pressing View.

  4. Create a response for the player by pressing Add Dialogue and then right-clicking the priority number.

  5. Change the response text to “How’s your morning?”

  6. Enter the response’s children by pressing View.

  7. Create a new message by pressing Add Dialogue.

  8. Right-click the message text. This should turn the message into a response, and turn its background blue!

  1. Left-click the redirect text and enter the priority number of the thank you message our buddy says to us when it’s the afternoon.

Note: For this tutorial, it’s 1.2.1.1, but you can get this by combining the viewing priority from your console’s output, adding a ., and adding the number of the message you want.

  1. Press enter to save your redirect!

Now, it’s time for us to wait until the morning for us to test if this worked. Good night!

(10 hours later… Let’s imagine I didn’t just flip the sign used in the before action to save time)

So far so good…

We did it!

Talk about a “one-on-one” conversation.

16 Likes