Minecraft:Commands/scriptevent
From SAS Gaming Wiki
More actions
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".,
- REDIRECT Template:Command
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
See also
- REDIRECT Template:Command
Template:Redr— debugging options for GameTest Framework
External links
de:Befehl/scriptevent zh:命令/scriptevent