5E Product Walkthrough Playlist
  1. #1

    onReceiveMessage FGU question

    Hello all,

    I am using the onReceiveMessage because I want to have the option to remove some of the message (I want the DC not to display if the DM has that option turned on).

    In the API it says:

    Code:
    Return values
    
    (boolean)
    If true, the message is not processed any further, omitting it from the chat history.
    So it sounds to me that if you edit the "messagedata" it should output the new text right?

    Even if not, then returning true should stop it appearing in the chat window?

    For me neither seem to work, the message is still displayed as if nothing was changed/edited in the chat box.

    Rulseset = 5e.


    Code:
    function onReceiveMessage(msg)
    	Debug.console("rfia_options_manager.lua msg", msg);
    	msg.text = string.gsub(msg.text, "%[vs. DC %d+%]", "%[vs. DC ?]");
            Debug.console("rfia_options_manager.lua msg after parse", msg);
    	return false;
    end
    In the above code the console output does as expected and the msg has been parsed. However, the msg displays as normal in the chat for all users.

    Code:
    function onReceiveMessage(msg)
    	Debug.console("rfia_options_manager.lua msg", msg);
    	msg.text = string.gsub(msg.text, "%[vs. DC %d+%]", "%[vs. DC ?]");
            Debug.console("rfia_options_manager.lua msg after parse", msg);
    	return true;
    end
    In the above code the console output does as expected and the msg has been parsed. However, in this case wouldnt you expect that no message at all is displayed in the chat?

    Thank you for your help!

  2. #2
    There is no return data in the function to modify the message. You are only receiving notification of the message.

    If you return "false"/"nil", then you are telling the FG client to continue standard processing.
    If you return "true" then you are telling the FG client to NOT perform standard processing.

    Since you are trying to intercept specific roll types, you're better off overriding the specific roll scripts to do what you want.

    Regards,
    JPG

  3. #3
    Thank you Moon Wizard,

    I must admit I do not know what "standard processing" means?

    I really want to avoid overriding, so far I've only had to steal a handler, but then I always call the original handler's method; this has helped keep my mod compatible with others and also means that if 5E changes code I wont have to change anything (hopefully).

    I will take another look, but I think I will just not implement it, its more of a nice to have feature .

  4. #4
    Standard processing means the default actions/behaviors that FG performs when that event occurs. You either return true to let it do what it normally does; or return false to tell it to stop.

    I get what you're saying about minimizing impacts; but it sounds like the specific handler overrides are the way to go in your situation.

    Regards,
    JPG

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
  •  
5E Character Create Playlist

Log in

Log in