I have managed to this before, by accident, but i can't repeat it when i actually want it to happen. I have two dummy scripts set up to try to figure out how to get this working. What am I missing? The two scripts are almost identical, and are listed below. The important part is the getFromSource function in the first script, which is trying to call a sourceFunction in the second script. Just calling the function by name doesnt work, nor does prepending the script 'namespace'. If I try let eureka = sourceFunction(); I get ReferenceError: sourceFunction is not defined If I try let eureka = sourceTest.sourceFunction(); I get TypeError: sourceTest.sourceFunction is not a function Do i have to do something to expose the function in someway? Maybe in the RegisterEventhandlers function? I include the complete scripts below, but they are basic scaffolding, just to test this process. Script One var originTest = originTest || (function() {
'use strict';
var version = '0.1',
handleInput = function(msg) {
var args = msg.content.split(",");
if(msg.type == "api" && msg.content.indexOf("!originTest") !== -1) {
var args = msg.content.split("--");
getFromSource();
} else {
return;
}
},
getFromSource = function() {
let eureka = sourceTest.sourceFunction(); // TypeError: sourceTest.sourceFunction is not a function
//let eureka = sourceFunction(); // ReferenceError: sourceFunction is not defined
sendChat('originTest', eureka);
},
registerEventHandlers = function() {
on('chat:message', handleInput);
};
return {
RegisterEventHandlers: registerEventHandlers
};
}());
on("ready",function(){
'use strict';
originTest.RegisterEventHandlers();
});
Script Two var sourceTest = sourceTest || (function() {
'use strict';
var version = '0.1',
handleInput = function(msg) {
// this is a dummy script so doesnt need anything here
},
sourceFunction = function() {
return 'Eureka - we have landed!';
},
registerEventHandlers = function() {
on('chat:message', handleInput);
};
return {
RegisterEventHandlers: registerEventHandlers
};
}());
on("ready",function(){
'use strict';
sourceTest.RegisterEventHandlers();
});