Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Commands/scriptevent: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Remove broken links to missing pages
SyncBot (talk | contribs)
Fix template calls: add MC/ prefix
 
Line 1: Line 1:
{{distinguish|Commands/script}}
{{MC/Distinguish|Commands/script}}
{{exclusive|bedrock|education}}
{{MC/Exclusive|bedrock|education}}
{{Infobox command
{{Infobox command
| name = scriptevent
| name = scriptevent
Line 12: Line 12:


==Arguments==
==Arguments==
{{argument|be=1|messageId: string|basic_string}}
{{MC/Argument|be=1|messageId: string|basic_string}}
:Must be a string. Must be namespaced and use of the minecraft namespace is invalid (e.g. {{Command|scriptevent give:coal}}, {{Cmd|scriptevent my_scripts:spawn_sheep}})
:Must be a string. Must be namespaced and use of the minecraft namespace is invalid (e.g. {{MC/Command|scriptevent give:coal}}, {{MC/Cmd|scriptevent my_scripts:spawn_sheep}})


{{argument|be=1|message: message|CommandMessage}}  
{{MC/Argument|be=1|message: message|CommandMessage}}  
:Optional argument. Maximum length is the C++ max string length. {{arg desc|be=CommandMessage}}
:Optional argument. Maximum length is the C++ max string length. {{MC/Arg desc|be=CommandMessage}}


==Result==
==Result==
Line 45: Line 45:


*To evoke an event handler with the ID wiki:example and the message "Example Message":
*To evoke an event handler with the ID wiki:example and the message "Example Message":
**{{Code|code=/scriptevent wiki:example Example Message}}
**{{MC/Code|code=/scriptevent wiki:example Example Message}}
*Example JavaScript code for use in the scripting API:
*Example JavaScript code for use in the scripting API:
<syntaxhighlight lang="javascript" line="1">
<syntaxhighlight lang="javascript" line="1">
Line 65: Line 65:


{{HistoryTable
{{HistoryTable
|{{HistoryLine|bedrock}}
|{{MC/HistoryLine|bedrock}}
|{{HistoryLine||Beta APIs<br>(Experimental)|link=Bedrock Edition 1.19.60|dev=Preview 1.19.60.22|Added {{cmd|scriptevent|link=none}} behind the "Beta APIs" experimental toggle.}}
|{{HistoryLine||Beta APIs<br>(Experimental)|link=Bedrock Edition 1.19.60|dev=Preview 1.19.60.22|Added {{MC/Cmd|scriptevent|link=none}} behind the "Beta APIs" experimental toggle.}}
|{{HistoryLine||1.20.30|dev=Preview 1.20.20.20|{{cmd|scriptevent|link=none}} is no longer behind "Beta APIs" experimental toggle.}}
|{{HistoryLine||1.20.30|dev=Preview 1.20.20.20|{{MC/Cmd|scriptevent|link=none}} is no longer behind "Beta APIs" experimental toggle.}}
}}
}}


==See also==
==See also==


*{{Cmd|script}}— debugging options for GameTest Framework
*{{MC/Cmd|script}}— debugging options for GameTest Framework


== External links ==
== External links ==
Line 79: Line 79:


== Navigation ==
== Navigation ==
{{Navbox commands}}
{{MC/Navbox commands}}


de:Befehl/scriptevent
de:Befehl/scriptevent
zh:命令/scriptevent
zh:命令/scriptevent

Latest revision as of 20:13, 9 April 2026

Template:Hatnote Script error: No such module "Exclusive". Template:Infobox command Triggers a script event with an ID and message.

Syntax

scriptevent <messageId: string> <message: message>

Arguments

messageId: string: basic_string

Must be a string. Must be namespaced and use of the minecraft namespace is invalid (e.g. Script error: No such module "command".,
  1. REDIRECT Template:Command

Template:Redr)

message: message: CommandMessage

Optional argument. Maximum length is the C++ max string length. {{#vardefine:onlyje|Template:IN,}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|message}}Template:Error{{#vardefine:onlyje|}}{{#vardefine:onlybe|}}{{#vardefine:je-arg|}}{{#vardefine:be-arg|}}

Result

Template:Result table Template:Result table Template:Result table Template:Result table

The command by itself does not directly affect anything in the game, but can trigger an event in any add-ons applied to the world/server.

Output

Command Edition Situation Success Count
any Minecraft:Bedrock Edition On fail 0
On success 1

Example

  • To evoke an event handler with the ID wiki:example and the message "Example Message":
    • /scriptevent wiki:example Example Message
  • Example JavaScript code for use in the scripting API:

<syntaxhighlight lang="javascript" line="1"> import { system } from "@minecraft/server";

system.afterEvents.scriptEventReceive.subscribe((event) => {

 const {
 	id,           // returns string (wiki:example)
 	initiator,    // returns Entity
   message,      // returns string (Example Message)
   sourceBlock,  // returns Block
   sourceEntity, // returns Entity
   sourceType,   // returns MessageSourceType
 } = event;

}); </syntaxhighlight>Code source

History

Template:HistoryTable

See also

  1. REDIRECT Template:Command

Template:Redr— debugging options for GameTest Framework

External links

Navigation

All editions
Removed
Template:El only
Debug
Removed
Template:Els only
Template:El only
Removed
Template:El only
Removed
Template:Els only
Removed
Joke
Related

de:Befehl/scriptevent zh:命令/scriptevent