Skip to main content

How to create a delay in NPC "chat" with command blocks?

Comments

13 comments

  • Sarah Elliott
    Bug Zapper Super Star

    Have you tried increasing the tick delay in the command block? (You have to scroll down in the left panel)

    2
  • Diaa Neumos

    I honestly didn't know that would do it. Is it larger numbers = longer delays?

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    Super helpful, Sarah Elliott Does the tick delay have to be reset afterwards?

    1
  • Jasper Rutten

    Hey Diaa Neumos,

    There are a couple of ways you can do this. If you want to use chat I recommend combining your command blocks with a scoreboard. You can also use the NPC dialogue window when you right click them.

    Using scoreboard:

    If you don't know how to use scoreboards, here is the wiki: https://minecraft.fandom.com/wiki/Scoreboard
    Look for bedrock/edu commands, not java.

    Make a scoreboard that acts as a timer, have it go up by 1 every tick for everyone that already has the scoreboard above 1. do this using a repeat commandblock.

    /scoreboard players add @a[scores={timer=1..}] timer 1

     

    Then add some other command blocks that test for a specific score using execute command.

    /execute @a[scores={timer=20}] ~ ~ ~ say your message

    You can add multiple command blocks with different timer values to add more NPC dialogue.
    In Minecraft 20 ticks = 1 second, so just multiply the time you want between messages by 20.

    Finally add 1 more command blocks that checks when you have reached the end. (highest scoreboard value)

    /scoreboard players set @a[scores={timer=101..}] timer 0

    In this command we assume that the last chat message is after 100 ticks (5 seconds).
    If you add more dialogue, extend the timer value in this commandblock.

    Now all you have to do to start the dialogue is set the scoreboard value of the timer for the player to 1, you can do this in the NPC or with a commandblock.

    /scoreboard players set @s timer 1


    Using the dialogue window:

    You can make an NPC have multiple dialogue windows and even things like branching paths. This is done using Datapacks. It relatively easy to do, but requires a little technical know how.

    Here is the documentation: https://wiki.bedrock.dev/entities/npc-dialogs.html

    Let me know if you need further explanation or help. 
    Hope this helped. 

    3
  • Sarah Elliott
    Bug Zapper Super Star

    Diaa Neumos yep, the bigger the number, the longer the delay!  The first time I used it was actually in one of my elevator designs -- I have a block that teleports the player from one "elevator" to another chained to a block that goes "ding," and it just didn't FEEL right until I delayed the ding for a bit.  :D  Ticks run fast, though. so you may find you need a number with a couple of zeroes after it if it's for dialogue.

    Debbie Alexander Nope. It'll stay that way in the command block just like the command does until you change it.

    2
  • Diaa Neumos

    Thanks Sarah Elliott and Jasper Rutten, I appreciate the help from both of you!

    Sarah, your suggestion worked like a charm; thank you so much!

    Jasper, I'm not actually using an actual NPC like a Villager, but rather a large and inanimate "NPC" that I created with blocks. Sorry, I should have been more clear!

    That aside, I've now run into another problem with my "planned design"... I apologize in advance, as it seems I'm rather Redstone illiterate, LOL!

    My idea is to have the player teleported to a platform made with Barriers, facing the "NPC" (referred to as "the speaker" from here on out to avoid the previous confusion), and have the speaker recite his dialogue... and to do this for every player that joins what I hope to eventually be a public realm.

    I got the teleportation to the platform facing the speaker down just fine... and I got the dialogue with timing down just fine... but something about my connection between them is off because in test runs, the speaker will teleport the player every time they come close to the teleportation spot as intended, but the speaker only recites his lines once... and then he stops. He won't do his lines again, even if the player is teleported back...

    I'm not sure if it's the way I have it set up, or the options I've selected, or what, but any advice would be greatly appreciated as I've tried a few different things and none of them are working...! :( 

    0
  • Dani Noble
    Moderator Beacon of Knowledge Super Star

    For something like that, I'd use a /testfor command in one block: 

    /testfor @p [r=3] where the "r" is the radius around the block that you want players detectable.       

    And then link it to a block with a /tellraw command: 

    /tellraw @p {"rawtext":[{"text":"§9§lShopkeep:§r§f You've bought an iron pick axe."}]}

    If you'd like a wee in person tutorial or look at other options, let me know here and I can get the admins to exchange our emails.  

    1
  • Diaa Neumos

    Thank you, Dani Noble That's sort of what I used, only /say instead of /tellraw, but something is off with the way I either have it set up or have the settings entered because it won't repeat the lines (the /say commands) every time someone is teleported. The teleport always works, just not the lines every time.

    I would love to see what you have, as that would probably help me tremendously! Thank you for offering that to me! :) 

    0
  • Dani Noble
    Moderator Beacon of Knowledge Super Star

    Hi Penny, Justin would you be able to exchange my and Diaa Neumos emails for us?

    Thanks! 

    1
  • Penny Support
    Bug Zapper Super Star Beacon of Knowledge Support

    Done!

    0
  • Diaa Neumos

    Penny I don't see anything that would be Dani Noble 's email. Where should I be looking? I tried searching my email for Penny and Minecraft search words for all email items and nothing came up except the zendesk contact for Minecraft.

    0
  • Dani Noble
    Moderator Beacon of Knowledge Super Star

    Hi Diaa Neumos

    Sorry, just sent you an email now! 

     

    1
  • Diaa Neumos

    Hey Dani Noble, no worries at all! I just wasn't sure what to expect or what to look for as I've never done this before! I got your email safely out of my Spam folder (it automatically went there) and am going to reply now. :) 

    0

Please sign in to leave a comment.