If you don't set Sphere.Game.version to 1 in your Cellscript, the default is 2. In that case your main script will be loaded as a CommonJS module (like node) rather than normal program code (like Sphere 1.x/browsers). You have a few options: A) Set the API version to 1; B) Explicitly make the variable global global.objects = ...; or C) Take advantage of closures and pass a function to SetDefaultMapScript().
// mainglobal.somepkg = require('somepkg');global.otherpkg = require('otherpkg');
global.somepkg = require('somepkg');
install("@/scripts",files(/scripts\/.*(^bak)\.js$/, true));
(function() { // your module code here})()
CommonJS is pretty simple to understand, just pretend the whole module is wrapped inside of:Code: [Select](function() { // your module code here})()...which is exactly what the engine does under the hood when loading them. That way any vars, functions, etc. are local to the module. By assigning something to global you explicitly put it in global scope, the same as adding stuff to window in a browser.SetDefaultMapScript() etc. basically work like eval(), anything in there is effectively run in the global scope. Unlike Sphere 1.x, miniSphere lets you pass a function to them instead though, if you wanted to take advantage of normal scoping rules.
Regarding Cellscript regular expressions, I actually wanted to implement that originally, but it's pretty hard right now because files() is implemented natively and Duktape doesn't expose its regex engine to C code. I didn't want to add a dependency on a third-party regex engine just for the sake of pattern matching files. Maybe I'll put in a feature request on the Duktape repo...
By the way, tip: requires are cached. So if you do require('something') in multiple places, only the first one will actually load the module and the rest will just return the cached exports. So you get built-in lazy loading that way without needing to store it globally.
Oh, and you never answered my question. In the meantime, until regular expressions are allowed, or if they aren't at all, is scriptname.bak.js a common practice in case a major change doesn't work out?
Is there no available Regex engine that can be implemented similar to Duktape (i.e. you provide the source and header files in your own code rather than linking)? It seems especially strange, considering the RegExp constructor is available.
I use Linux a lot, and according to WineHQ, it doesn't run, or runs terribly.