Script.include fails


When using Script.include to include another javascript file a warning message occurs: QObject::connect: Cannot queue arguments of type ‘QMap’
(Make sure ‘QMap’ is registered using qRegisterMetaType().
The included script is not initialised and lead to an Error like :
Uncaught exception at ( “Entities” ) line 18 : "ReferenceError: Can’t find variable: ChangeColorOnHover"
To replicate the Error, just put
in the ScriptURL of an Entity.
I also tried this with a script that does nothing else then including a second Script that only consists of an empty object ( no data, no functions ), with the same Result, so i’m confident, it’s the include that causes the Error.

I tested with 2666 on OS X. I can’t say if this also occurs with Windows.




This is also an issue on Linux.

The net effect is that entity scripts can no longer use Script.include to include resources – because the globals defined within never become accessible to the surrounding script context.

On the C++ side this appears to have something to do with the ‘Entities’ scripting sandbox.

As a temporary workaround XHR can be used to fetch resources. To try out the hover change script you could paste the below whole (function(){…})) block into ScriptURL (which accepts both URLs and short JavaScript constructor snippets):

(function() {

  Script.$include = function(src) {
    var xhr = new XMLHttpRequest();"GET", src, false); /* false == synchronous */
    /* should really do some error checking here...*/

  return new ChangeColorOnHover();


Hi @humbletim,

yep, that works, thanks for the workaround.