I gave a quick try to this long existing feature request, to support having object interaction and event functions in any script module besides Global Script.
https://github.com/adventuregamestudio/ags/pull/2534
Making this work on the engine's side was pretty simple. Although in the implementation that I tried engine tests every script for the matching symbol, which may make running interaction somewhat slower, depending on the number of modules. I doubt that would be a performance problem, since this uses fast lookup tables, and normally happens as a reaction to player input. But there's definitely a room for improvement here. Either the script name may be saved along with the function name during game compilation; I suppose that would be a reasonable thing to do. Or it may be cached at runtime after running the event for the first time (or do this in case compiled data does not contain a script name).
But frankly I was more bothered about Editor's side of this issue, where "..." should do something more than leading to a global script.
This made me step back and think that it may be a smarter thing to save script name alongside with the function name. In other words, have strings like "GlobalScript.asc::cEgo_Interact". And if it does not have a script name, then assume it's a GlobalScript. This might work well at least if saved in compiled game, but also may work if used in the events fields. Maybe...
I suppose further, that maybe the Editor may automatically copy the previously used script name from assigned events when you create a new handler. For example, if you have a Character, and you have already assigned a "MyCustomModule.asc::cEgo_Interact" for Interact event, then you press [...] button for Look event, editor will insert "MyCustomModule.asc::cEgo_Look". If there are multiple scripts names used in these events for some reason, then maybe the first found one is used (?).
I am posting these thoughts here, willing to make a small pause and think this over again, but maybe somebody has ideas too. Unfortunately, even though the ticket exists for a very long time now (https://github.com/adventuregamestudio/ags/issues/485), there was not much discussion of this. Unless there had been one on forums and I missed it.
https://github.com/adventuregamestudio/ags/pull/2534
Making this work on the engine's side was pretty simple. Although in the implementation that I tried engine tests every script for the matching symbol, which may make running interaction somewhat slower, depending on the number of modules. I doubt that would be a performance problem, since this uses fast lookup tables, and normally happens as a reaction to player input. But there's definitely a room for improvement here. Either the script name may be saved along with the function name during game compilation; I suppose that would be a reasonable thing to do. Or it may be cached at runtime after running the event for the first time (or do this in case compiled data does not contain a script name).
But frankly I was more bothered about Editor's side of this issue, where "..." should do something more than leading to a global script.
This made me step back and think that it may be a smarter thing to save script name alongside with the function name. In other words, have strings like "GlobalScript.asc::cEgo_Interact". And if it does not have a script name, then assume it's a GlobalScript. This might work well at least if saved in compiled game, but also may work if used in the events fields. Maybe...
I suppose further, that maybe the Editor may automatically copy the previously used script name from assigned events when you create a new handler. For example, if you have a Character, and you have already assigned a "MyCustomModule.asc::cEgo_Interact" for Interact event, then you press [...] button for Look event, editor will insert "MyCustomModule.asc::cEgo_Look". If there are multiple scripts names used in these events for some reason, then maybe the first found one is used (?).
I am posting these thoughts here, willing to make a small pause and think this over again, but maybe somebody has ideas too. Unfortunately, even though the ticket exists for a very long time now (https://github.com/adventuregamestudio/ags/issues/485), there was not much discussion of this. Unless there had been one on forums and I missed it.