What I want to do is make a command that allows me to say something like "home" in the chat, and have a command block teleport me to my house. Is there a way to test for a word in chat?
4 Answers
You cannot test for what someone has said in chat. You could however set up your own custom /trigger
commands.
You can do this by first creating a "trigger" type scoreboard objective:
/scoreboard objectives add home trigger
Then enable it for whoever you want to be able to use it:
/scoreboard players enable @a home
Any player who has it enabled, even non-OPs, can now use /trigger home set
or /trigger home add
to manipulate their "home" scoreboard objective.
You can add a /tp @a[score_home_min=1] X Y Z
on a clock to have it so anyone who does /trigger home set 1
in chat is teleported home. Follow it up with setting their home score back to 1, so they aren't constantly teleported, and re-enable the objective for them, so they can use it again.
-
Sorry if I missed something, but how does this test if the player is saying something in chat?– 2xedoCommented Mar 27, 2015 at 19:23
-
2@tuxedoandex It tests if the player types
/trigger home
into chat. It won't appear in chat for other players as it's a command, but appearing in chat for other players to see does not seem to be a requirement for OP's question. It's more of a workaround than exactly what was wanted, but it should still work.– SirBenetCommented Mar 27, 2015 at 19:49 -
THIS CHANGES EVERYTHING! you could make reformatted commands so typing "/trigger spawn" would teleport you to spawn, thus bypassing the needs for plugins! THANK YOU!!! Commented Nov 30, 2016 at 5:06
Not in vanilla Minecraft, no. There is no way in vanilla Minecraft on a vanilla server to implement any sort of custom chat commands, or detect any sort of chat events.
In addition to the above answer, if you're using the home functionality, you might also want to repeat the steps above to create a sethome trigger, then use a command to set an armorstand there with a unique name.
See How to enable home / sethome on a Vanilla Minecraft Server
Yes, it's possible to /testfor
if someone is saying something in chat but you need plugins (/testforchat
). Then you put in any text that you want the player to say and then you can mess around with it.
-
1
/tellraw
commands that have a click event which causes the player to choose what they say, and control functioal reactions by settingclickEvent
areas to place redstone blocks in a possibly remote system.