You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== tellraw ==
Copy Code
The output might be:
Copy Code
The output might be:
A thin wrapper around the tellraw command from console context, this simply passes the input to the command. The raw is passed in as an array and json encoded. No validation is done on the input, so the command may fail. Do not use double quotes (smart string) when providing the selector. If not provided, the selector defaults to @a. See {{function|ptellraw}} if you need player context.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| tellraw
|-
! scope="row" | Returns
| void
|-
! scope="row" | Usages
| [string selector], array raw
|-
! scope="row" | Throws
| [[../objects/ms.lang.CastException|ms.lang.CastException]]
|-
! scope="row" | Since
| 3.3.4
|-
! scope="row" | Restricted
| Yes
|-
! scope="row" | Optimizations
| None
|}The specification of the array may change from version to version of Minecraft, but is documented here https://minecraft.gamepedia.com/Commands#Raw_JSON_text. This function is simply written in terms of json_encode and runas, and is otherwise equivalent to runas('~console', '/minecraft:tellraw ' . @selector . ' ' . json_encode(@raw))
=== Usages ===
tellraw([string selector], array raw)=== Examples === ====Example 1==== Simple usage with a plain message Given the following code:
tellraw(array('text': 'Hello World!'));

1 {{function|tellraw}}({{function|array}}('text': 'Hello World!'));
<<Would output the plain message to all players.>>====Example 2==== Using a selector Given the following code:
tellraw('@a[gamemode=spectator]', array('text': 'Hello World!'));

1 {{function|tellraw}}('@a[gamemode=spectator]', {{function|array}}('text': 'Hello World!'));
<<Would output the message to all spectators.>>===See Also===
[[API/functions/ptellraw.html|ptellraw]]
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)