DICE PACKS BUNDLE
  1. #1

    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
    And if works fine in FG Unity, but FG Classic gives me "attempt to set a value for an invalid handler" error.

    Can I do something about it?
    Thanks in advance

  2. #2
    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

  3. #3
    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?

  4. #4
    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

  5. #5
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in