Forumskeyboard_arrow_right Help keyboard_arrow_right Java Edition

Create Forum Thread
1

Is there a command to detect if player says something specific in chat?

1 emeralds8 replies134 views
created 07/18/2019 2:19 pm by Jmanch3w
last reply 07/19/2019 8:08 pm
I'm making a RPG dialogue system in 1.14.3 using command blocks. Basically the Character will say something to start the conversation and then a command block will /tellraw some colored text saying "Option 1: ("Whatever option one is")" and then option 2, 3, etc. Then the player simply types in chat, the number of the option they pick. When you pick option 1 for example it will be detected by a command block and the character would respond with an answer that corresponded to what you said. Everything is fine except that I have no clue how to detect if player types a certain number in chat. Since /testfor no longer exist I don't know how. I know that /tellraw has click events but I was wondering if there is a simpler way because /tellraw is entire new format and requires very very long lines of code. (I've also heard it takes forever and is buggy and do not have time for that.) Any help is greatly appreciated.
Posted by avatar
Jmanch3w
Level 10 : Journeyman Architect
15

comment Login or register to post a reply.

8 replies

1
07/19/2019 10:02 amhistory
Level 19 : Journeyman Nerd
dusan1710
The Bukkit API (and Spigot by extension) support the AsyncPlayerChatEvent, it can return the string of the message, as well as info about the player who said it. Via a simple RegEx or just with a substring check (or an .equalsIgnoreCase()) you can check against a list of options, or just capture the entire string, if you need things like names entered. You can then add rules like how many words it can have by more of the above. If you know Java, you can easily make a plugin that handles this and passes the data off to whatever plugin you use for classes and stuff. It can’t be done via command blocks, so you’d have to ditch those.

Not a command, but still a possible option.



Edit: Not sure if you are making a single player map, then nothing really works. Just re-read your question and seems like that’s the case.

Cheers,
Dusan
1
07/19/2019 5:29 pm
Level 10 : Journeyman Architect
Jmanch3w
it is a single player map. I know there has got to be a way to do this with commands...I'm really close... Since then I have switched to click events where you click and it gives a select score on a objective which would activate the next click even (Dialogue tree)...the problem I have now is that once these click events are powered you have to send another signal to update the execute if command (testfor) but I can't put a clock and I can't put a repeat command block because I only want the dialogue to show up once. Literally all I need is the command block to testfor a score and activate once....this is so simple that I'm finding it hard to believe it can't be done.
1
07/19/2019 8:08 pmhistory
Level 19 : Journeyman Nerd
dusan1710
I’m not sure, but maybe this helps?
1
07/19/2019 3:36 am
Level 8 : Apprentice Modder
HoboMaggot
Theres no vanilla command that supports this feature, but i'm pretty sure there's a plugin that allows this.
1
07/19/2019 9:27 am
Level 10 : Journeyman Architect
Jmanch3w
Ok. Since then I have switched to click events where you click and it gives a select score on a objective which would activate the next click even (Dialogue tree)...the problem I have now is that once these click events are powered you have to send another signal to update the execute if command (testfor) but I can't put a clock and I can't put a repeat command block because I only want the dialogue to show up once. Idk how to fix this. Is there a way to have a repeat command block but it only sends one output then stops?
1
07/19/2019 11:39 am
Level 42 : Master Cowboy
CrazyCowMM
Simply have the repeating command block executing at player with or without a certain tag and then in a chain command block after it add or remove that tag.

For example:
  • In the repeating command block: /tellraw @a[tag=!told1] {"text":"Hello! Have you heard..."}
  • Then in the chain command block: /tag @a add told1
Chain would be conditional obviously
1
07/18/2019 2:24 pm
Level 42 : Master Pixel Puncher
CiscuLog
It's a shame, but no command allows this
1
07/18/2019 2:27 pm
Level 10 : Journeyman Architect
Jmanch3w
This has to be one of the dumbest decisions Mojang has made in my time playing minecraft.

Planet Minecraft

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome