PDA

View Full Version : onReceiveMessage FGU question



Houndy
April 30th, 2020, 15:56
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:


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.



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.


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!

Moon Wizard
May 1st, 2020, 01:07
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

Houndy
May 1st, 2020, 11:05
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 :).

Moon Wizard
May 1st, 2020, 22:19
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