diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx
index 88cd7e379..1c93b9cfc 100644
--- a/src/Scripting/NasalSys.cxx
+++ b/src/Scripting/NasalSys.cxx
@@ -385,7 +385,7 @@ void FGNasalSys::loadPropertyScripts()
         const char* src = n->getStringValue("script");
         if(!n->hasChild("script")) src = 0; // Hrm...
         if(src)
-            initModule(module, n->getPath(), src, strlen(src));
+            createModule(module, n->getPath(), src, strlen(src));
 
         if(!file_specified && !src)
             SG_LOG(SG_NASAL, SG_ALERT, "Nasal error: " <<
@@ -422,14 +422,14 @@ void FGNasalSys::loadModule(SGPath file, const char* module)
         return;
     }
 
-    initModule(module, file.c_str(), buf, len);
+    createModule(module, file.c_str(), buf, len);
     delete[] buf;
 }
 
 // Parse and run.  Save the local variables namespace, as it will
 // become a sub-object of globals.
-void FGNasalSys::initModule(const char* moduleName, const char* fileName,
-                            const char* src, int len)
+void FGNasalSys::createModule(const char* moduleName, const char* fileName,
+                              const char* src, int len)
 {
     naRef code = parse(fileName, src, len);
     if(naIsNil(code))
@@ -476,16 +476,24 @@ bool FGNasalSys::handleCommand(const SGPropertyNode* arg)
     // location in the property tree.  arg->getPath() returns an empty
     // string.
     const char* nasal = arg->getStringValue("script");
+    const char* moduleName = arg->getStringValue("module");
     naRef code = parse("<command>", nasal, strlen(nasal));
     if(naIsNil(code)) return false;
-    
+
+    naRef locals = naNil();
+    if (moduleName[0]) {
+        naRef modname = naNewString(_context);
+        naStr_fromdata(modname, (char*)moduleName, strlen(moduleName));
+        if(!naHash_get(_globals, modname, &locals))
+            locals = naNewHash(_context);
+    }
     // Cache the command argument for inspection via cmdarg().  For
     // performance reasons, we won't bother with it if the invoked
     // code doesn't need it.
     _cmdArg = (SGPropertyNode*)arg;
 
     // Call it!
-    naRef result = naCall(_context, code, naNil(), naNil(), naNil());
+    naRef result = naCall(_context, code, naNil(), naNil(), locals);
     if(!naGetError(_context)) return true;
     logError();
     return false;
diff --git a/src/Scripting/NasalSys.hxx b/src/Scripting/NasalSys.hxx
index 8efb3159f..6f9df4953 100644
--- a/src/Scripting/NasalSys.hxx
+++ b/src/Scripting/NasalSys.hxx
@@ -42,6 +42,9 @@ public:
     // Callbacks for command and timer bindings
     virtual bool handleCommand(const SGPropertyNode* arg);
 
+    void createModule(const char* moduleName, const char* fileName,
+                    const char* src, int len);
+
 private:
     friend class FGNasalScript;
 
@@ -58,8 +61,6 @@ private:
     };
 
     void loadPropertyScripts();
-    void initModule(const char* moduleName, const char* fileName,
-                    const char* src, int len);
     void hashset(naRef hash, const char* key, naRef val);
     void logError();
     naRef parse(const char* filename, const char* buf, int len);