Module SpellMessages
Send messages to warn the party about party utilities being used.
Functions
PrepareSendChatMessage (message) | Prepare the message to be sent to the relevent chat channel. |
SpellMessage:new (spellId, itemId, sentMsg, startedMsg, interruptedMsg, stoppedMsg, succeededMsg, plural, target, group) | Creates a new spell message object with the given parameters. |
SpellMessage:soulstoneMessage (msgType, isAlive) | Generates a message based on the given `msgType` and `isAlive` parameters. |
SpellMessage:buildString (prefix, key) | Builds a message based on the given `prefix` and `key` parameters as well as the fields of the object. |
SpellMessage:queueMessages () | Queues the messages to be sent to the chat channel. |
SpellMessage:dequeueMessages () | Dequeues the messages from the message queue. |
PlayerCastSent (unit, spellId) | This function is called when a player casts a spell and the cast is sent to the server. |
PlayerCastInterrupted (unit, spellId) | This function is called when a player casts a spell and the cast is interrupted. |
PlayerCastSucceeded (unit, spellId) | This function is called when a player casts a spell and the cast is successful. |
NpcCastStart (unit, spellId) | This function is called when an NPC casts a spell and the cast is started. |
NpcCastSucceeded (unit, spellId) | This function is called when an NPC casts a spell and the cast is successful. |
SummonedGuardian (...) | This function is called when an NPC casts a spell and the cast is interrupted. |
InterruptedSpellCast (...) | This function is called when an NPC casts a spell and the cast is interrupted. |
Functions
- PrepareSendChatMessage (message)
-
Prepare the message to be sent to the relevent chat channel.
Parameters:
- message (string) -- message to be sent
Usage:
`SpellMessages:PrepareSendChatMessage("Hello, World!")`
- SpellMessage:new (spellId, itemId, sentMsg, startedMsg, interruptedMsg, stoppedMsg, succeededMsg, plural, target, group)
-
Creates a new spell message object with the given parameters.
Parameters:
- spellId number -- The ID of the spell associated with the message.
- itemId number|boolean -- The ID of the item associated with the message. If no item is associated with the message, set this to `false`.
- sentMsg string -- The message to be displayed when the spell is sent.
- startedMsg string -- The message to be displayed when the spell is started.
- interruptedMsg string -- The message to be displayed when the spell is interrupted.
- stoppedMsg string -- The message to be displayed when the spell is stopped.
- succeededMsg string -- The message to be displayed when the spell is successful.
- plural boolean|nil -- (optional) Indicates whether the message should be pluralized.
- target boolean|nil -- (optional) Indicates whether the message should include the target's name.
- group boolean|nil -- (optional) Indicates whether the message should include the group's name.
Returns:
-
table -- The new spell message object.
Usage:
`SpellMessage(6201, 5512, "Making", "", "make", "", "made", true, false, true)` Note it is intended that empty strings will not generate a message.
- SpellMessage:soulstoneMessage (msgType, isAlive)
-
Generates a message based on the given `msgType` and `isAlive` parameters.
Parameters:
- msgType string The type of message. Defaults to "INTERRUPTED" if not provided.
- isAlive boolean Indicates whether the player is alive. Defaults to `false` if not provided.
Returns:
-
string The generated message based on the `msgType` and `isAlive` parameters.
Usage:
`soulstoneMessage(key, isAlive)` Intended to be used in the `buildString` function of a `newSpellMessage` object.
- SpellMessage:buildString (prefix, key)
-
Builds a message based on the given `prefix` and `key` parameters as well as the fields of the object.
Parameters:
- prefix (string) -- The prefix to be used in the message.
- key (string) -- The key to be used to retrieve the message from the `messages` table.
Returns:
-
(string | nil) -- The generated message based on the `prefix` and `key` parameters. Returns `nil` if the message is empty.
Usage:
`self:buildString(prefix, key)` Intended to be used in the `queueMessages` function of a `newSpellMessage` object.
- SpellMessage:queueMessages ()
-
Queues the messages to be sent to the chat channel.
Usage:
`self:queueMessages()` Intended to be used when a cast starts.
- SpellMessage:dequeueMessages ()
-
Dequeues the messages from the message queue.
Usage:
`self:dequeueMessages()` Intended to be used when the spell cast is interrupted or successful.
- PlayerCastSent (unit, spellId)
-
This function is called when a player casts a spell and the cast is sent to the server.
It retrieves the spell message associated with the spell ID and queues the messages.
It then prepares and sends a chat message using the prepared message queue.
Parameters:
- unit string The unit that casted the spell.
- spellId number The ID of the spell that was casted.
Usage:
`SpellMessages:PlayerCastSent("player", 12345)`
- PlayerCastInterrupted (unit, spellId)
-
This function is called when a player casts a spell and the cast is interrupted.
It retrieves the spell message associated with the spell ID and dequeues the messages.
It then prepares and sends a chat message using the prepared message queue.
Parameters:
- unit string The unit that casted the spell.
- spellId number The ID of the spell that was casted.
Usage:
`SpellMessages:PlayerCastInterrupted("player", 12345)`
- PlayerCastSucceeded (unit, spellId)
-
This function is called when a player casts a spell and the cast is successful.
It retrieves the spell message associated with the spell ID and dequeues the messages.
It then prepares and sends a chat message using the prepared message queue.
Parameters:
- unit string The unit that casted the spell.
- spellId number The ID of the spell that was casted.
Usage:
SpellMessages:PlayerCastSucceeded("player", 12345)
- NpcCastStart (unit, spellId)
-
This function is called when an NPC casts a spell and the cast is started.
It retrieves the spell message associated with the spell ID and queues the messages.
It then prepares and sends a chat message using the prepared message queue.
Parameters:
- unit any -- The unit that casted the spell.
- spellId any -- The ID of the spell that was casted.
- NpcCastSucceeded (unit, spellId)
-
This function is called when an NPC casts a spell and the cast is successful.
It retrieves the spell message associated with the spell ID and dequeues the messages.
It then prepares and sends a chat message using the prepared message queue.
Parameters:
- unit string -- The unit that casted the spell.
- spellId integer -- The ID of the spell that was casted.
Usage:
`SpellMessages:NpcCastSucceeded("target", _, 12345)`
- SummonedGuardian (...)
-
This function is called when an NPC casts a spell and the cast is interrupted.
It retrieves the spell message associated with the spell ID and dequeues the messages.
It then prepares and sends a chat message using the prepared message queue.
Parameters:
- ... any -- The arguments passed to the function.
Usage:
`SpellMessages:NpcCastInterrupted(...)`
- InterruptedSpellCast (...)
-
This function is called when an NPC casts a spell and the cast is interrupted.
It retrieves the spell message associated with the spell ID and dequeues the messages.
It then prepares and sends a chat message using the prepared message queue.
Parameters:
- ... any -- The arguments passed to the function.
Usage:
`SpellMessages:InterruptedSpellCast(...)`