Trigger Types

Trigger types are at the foundation of CT. These types determine when and how a trigger actually gets activated. All types go directly after the word "trigger" in the first line of a trigger, immediately following by a pair of parenthesis.

Example: trigger chat(hello) { chat hi! } In this example, the trigger type is "chat". An explanation for every trigger type is listed below.

chat
Chat types are used if you want to have a trigger read chat. It will attempt to match chat messages that fit the form specified in the trigger argument - in other words, the text between the parenthesis next to the event name.

Example: trigger chat(Hello!) { chat Hi! } Will output "Hi!" to the client whenever a message "Hello!" is received in chat.

onChat
Triggers with this type activate every single time a chat message is received, no matter what the chat message is. The trigger name does not matter

Example: trigger onChat(Cancel every chat message) { cancel }

other
The only way to trip a trigger with the type other is using "/tr " or through other triggers with the trigger event type in the form "trigger "

Example: trigger other(SetString) { do {string}.set(test) } Will set any given {string} to "test" when you run this trigger with "/tr SetString"

Example: trigger other(cool menu) { chat {br} chat This is a really cool menu chat {br} }

onWorldLoad
Triggers with this type will activate every time the Minecraft world is changed. In singleplayer, this will activate when joining the world, and when switching dimensions between the Nether, the End, and the Overworld. In Multiplayer, this will activate when joining a server, and every time the instance is changed. On servers that have many different instances in one network, it will activate every time you change to another one of those instances.

onWorldFirstLoad
Useful when dealing primarily with servers. Triggers with this type will activate only when joining a world for the first time. In single player, this trigger type will activate when joining the single player world, but not when switching dimensions. In Multiplayer, this trigger type will activate when joining the server, but will not activate on any successive instance changes.

onServerChange
Triggers when a new world is loaded in Minecraft and the client detects that it is a different IP from the last. Switching servers or going from single player to a server (or vice versa) are examples of this.

onNewDay
Triggers with this type will activate every time a new day occurs. This happens when your system date changes, not necessarily at a specific time.

onClientTick
Triggers with this type will activate every client tick (20 times a second), starting from the first time a world is joined (be it a singleplayer world or multiplayer).

onRightClickPlayer
Triggers with this type will activate every time you right click another player. Useful with the following built in strings:

{sneak} - tell if your player is sneaking

{player} - what player you right clicked

function
Similar to functions in any other programming language, though it is important to note that these are specifically string functions. Once you have defined a custom string function, you may use it on a string like any other string function.

Examples: trigger function($this.setHello) { return $this.set(Hello) }

trigger function($this.doTheMaths($arg1,$arg2)) { return $this.add($arg1).multiply($arg2) }

Every custom function's name must be in the form $this.FUNCTIONNAME. When making the events of a custom function, you may use $this to refer to any string that this function is modifying. Because I have used $this.set(Hello) in my function, any string that I use this function on (for example, {string }.setHello) will be set to "Hello".

Additionally, you must use the return event type, not the do event type. A function's purpose is to return a given value whenever it is used, therefore return must be used. Using do will return an error.

onUnknownError
Used by the mod for the automatic bug reporting feature, and will activate every time an error message is display in chat. Not very useful for pack creators, but it's a trigger type nonetheless.

onSoundPlay
Triggers whenever a sound is played. Provides plenty of built-in strings to give information about the sound.

Examples: trigger onSoundPlay(Sound Played) { chat {soundName} ///Chats the name of the sound (i.e. random.orb) chat {soundCategory} ///Chats the category in which the sound is played (i.e. ambient) chat {soundDistance} ///Chats how far away the sound was played chat {soundX} ///Chats the x coordinate of the sound chat {soundY} ///Chats the y coordinate of the sound chat {soundZ} ///Chats the z coordinate of the sound chat {soundVol} ///Chats the volume of the sound chat {soundPitch} ///Chats the pitch of the sound }