Passing a message to a module doesn’t really exist as a concept. The module just stores information, such as variables or functions.
Take this example module:
local M = {}
function M.pos()
print(go.get_position())
end
return M
If you call M.pos() from a script attached to a game object, what you will get is the position of that game object. The module itself does not have a position. So, in the same way, if we have a module like this:
local M = {}
function M.handle_message()
print(msg.url())
--do stuff to handle an incoming message
end
return M
And call the function in the on_message function of a script:
function on_message(self, message_id, message, sender)
M.handle_message()
end
Then the output of the print() will be the url of the script that is receiving the message, not the module. Because the module doesn’t have a url.
You might be using a module because multiple scripts share similar behaviours. Or you are storing variables in the module, so handling the message using a module function might make more sense (you could modify a variable local to the module that way).
Does this make sense?