From 4ce820279e4ebd916605f78a91f4dbd6a7651794 Mon Sep 17 00:00:00 2001 From: Thomas <72444570+Applevangelist@users.noreply.github.com> Date: Wed, 4 Mar 2026 13:53:03 +0100 Subject: [PATCH] Update Message.lua #MESSAGE Added :ToSet() and ToSetIf() --- Moose Development/Moose/Core/Message.lua | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Moose Development/Moose/Core/Message.lua b/Moose Development/Moose/Core/Message.lua index 1bbff44e7..7492bb997 100644 --- a/Moose Development/Moose/Core/Message.lua +++ b/Moose Development/Moose/Core/Message.lua @@ -198,6 +198,37 @@ function MESSAGE:ToClient( Client, Settings ) return self end +--- Sends a MESSAGE to a SET_GROUP, SET_UNIT, or SET_CLIENT. +-- @param #MESSAGE self +-- @param Core.Set#SET_GROUP Set The set to send to. +-- @param Core.Settings#SETTINGS Settings (Optional) Settings for message display. +-- @return self +function MESSAGE:ToSet(Set, Settings) + for _,_obj in pairs (Set:GetSetObjects() or {}) do + if _obj and _obj:IsAlive() then + if _obj:IsInstanceOf("SET_GROUP") then + self:ToGroup(_obj, Settings) + elseif _obj:IsInstanceOf("SET_CLIENT") or _obj:IsInstanceOf("SET_UNIT") then + self:ToUnit(_obj, Settings) + end + end + end + return self +end + +--- Sends a MESSAGE to a SET_GROUP, SET_UNIT, or SET_CLIENT if a condition is true. +-- @param #MESSAGE self +-- @param Core.Set#SET_GROUP Set The set to send to. +-- @param #boolean Condition The condition which needs to be true. +-- @param Core.Settings#SETTINGS Settings (Optional) Settings for message display. +-- @return self +function MESSAGE:ToSetIf(Set, Condition, Settings) + if Set and Condition == true then + self:ToSet(Set, Settings) + end + return self +end + --- Sends a MESSAGE to a Group. -- @param #MESSAGE self -- @param Wrapper.Group#GROUP Group to which the message is displayed.