-
September 1st, 2022, 00:10 #1
- Join Date
- Aug 2020
- Posts
- 94
Overriding Comm.deliverChatMessage
Hi All,
maybe this is a bad idea, but I would like to suppress some of the chat output by overriding Comm.deliverChatMessage.
I have the following code
Code:deliverChatMessage_old = Comm.deliverChatMessage Comm.deliverChatMessage = deliverChatMessage_override function deliverChatMessage_override(rMessage) local old_text = rMessage.text if string.find(rMessage.text, "Text to remove") then rMessage.text = "" end deliverChatMessage_old(rMessage) rMessage.text = old_text end
Can I do something about it?
Thanks in advance
-
September 1st, 2022, 04:01 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
That's a terrible idea to override, for any project other than one for your own personal situation. Many, many of the core capabilities of the system use that function; and there is an expectation of what people will see in chat. I would highly suggest rethinking the approach, and focusing on disabling or rewriting only the specific messages that you are trying to block.
If you really need to do that, there are some callback registration functions in the CoreRPG ChatManager script (registerDiceLandedCallback/registerDeliverMessageCallback/registerReceiveMessageCallback/registerDropCallback) that you can use.
Also, it will definitely not work in FG Classic.
Regards,
JPG
-
September 1st, 2022, 08:22 #3
- Join Date
- Aug 2020
- Posts
- 94
Thank you for the quick reply! I need to suppress the text of very particular chat messages that can only happen due to my extension. Is there a better way to do it? Anyway since I am storing the original Comm.deliverChatMessage and using it in my wrapper, what can actually go wrong? Also, is there a preferred way to distinguish between FGC and FGU in the code without having to rely on pcall?
-
September 1st, 2022, 08:47 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,561
What exact message is being sent due to your extension? Why not just change the code not to send the message at all?
You can run a Interface.getVersion() call to get the client version. (Major version >= 4 is FGU; Major version < 4 is FGC)
Regards,
JPG
-
September 1st, 2022, 23:38 #5
- Join Date
- Aug 2020
- Posts
- 94
In the end, I followed your advice and changed the code that sends the message, as an added bonus everything works exactly the same on FGC. Thank you!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks