public ActionScripted(string scriptPath, GameObject actor)
    {
        this.scriptPath = scriptPath;

        if (File.Exists(Application.dataPath + "/lua/" + scriptPath))
        {
            luaScript = new Script();
            luaScript.Options.ScriptLoader =
                new MoonSharp.Interpreter.Loaders.FileSystemScriptLoader();

            ((MoonSharp.Interpreter.Loaders.ScriptLoaderBase)
             luaScript.Options.ScriptLoader).ModulePaths =
                new string[] { Application.dataPath + "/lua/?",
                               Application.dataPath + "/lua/?.lua",
                               Application.dataPath + "/?",
                               Application.dataPath + "/?.lua" };
            luaScript.Options.DebugPrint = Debug.Log;

            LuaAPI.Register(luaScript);
            luaScript.Globals["actor"]   = actor;
            luaScript.Globals["Vector3"] = typeof(Vector3);
            luaScript.Globals["destroy"] =
                (Action <UnityEngine.Object>)GameObject.Destroy;

            try {
                luaScript.DoFile(Application.dataPath + "/lua/" + scriptPath);
            } catch (ScriptRuntimeException ex) {
                Debug.LogError("[ActionScripted] Could not read script: "
                               + ex.DecoratedMessage);
            } catch (SyntaxErrorException ex) {
                Debug.LogError("[ActionScripted] Could not read script: "
                               + ex.DecoratedMessage);
            }
        }
    }
    public void Initialize()
    {
        Script.GlobalOptions.RethrowExceptionNested = true;

        if (File.Exists(Application.dataPath + "/lua/" + scriptPath))
        {
            luaScript = new Script();
            luaScript.Options.ScriptLoader =
                new MoonSharp.Interpreter.Loaders.FileSystemScriptLoader();

            ((MoonSharp.Interpreter.Loaders.ScriptLoaderBase)
             luaScript.Options.ScriptLoader).ModulePaths =
                new string[] { Application.dataPath + "/lua/?",
                               Application.dataPath + "/lua/?.lua" /*,
                                                                    * Application.dataPath + "/?",
                                                                    * Application.dataPath + "/?.lua"*/};
            luaScript.Options.DebugPrint = Debug.Log;

            LuaAPI.Register(luaScript);
            luaScript.Globals["this"]          = luaScript;
            luaScript.Globals["gameObject"]    = gameObject;
            luaScript.Globals["sharedContext"] =
                new SharedContextProxy(sharedContext, luaScript);
            luaScript.Globals["Vector3"] = typeof(Vector3);
            luaScript.Globals["GO"]      = typeof(GameObject);
            luaScript.Globals["destroy"] =
                (Action <UnityEngine.Object>)GameObject.Destroy;
            luaScript.Globals["Time"]  = typeof(Time);
            luaScript.Globals["Input"] = typeof(Input);
            //luaScript.Globals["PhysicsAPI"] = typeof(PhysicsAPI);
            luaScript.Globals["Physics"]                 = typeof(Physics);
            luaScript.Globals["KeyCode"]                 = UserData.CreateStatic <KeyCode>();
            luaScript.Globals["Random"]                  = typeof(UnityEngine.Random);
            luaScript.Globals["MoveAction"]              = typeof(MoveAction);
            luaScript.Globals["ActionScripted"]          = typeof(ActionScripted);
            luaScript.Globals["ActionGetAsleep"]         = typeof(ActionGetAsleep);
            luaScript.Globals["ActionSleep"]             = typeof(ActionSleep);
            luaScript.Globals["ActionExecuteAfterDelay"] =
                typeof(ActionExecuteAfterDelay);

            Entity entity = gameObject.GetComponent <Entity>();
            if (entity != null)
            {
                luaScript.Globals["entity"] = entity;
            }

            if (simulation != null)
            {
                luaScript.Globals["simulation"] = simulation;
            }

            try {
                luaScript.DoFile(Application.dataPath + "/lua/" + scriptPath);
            } catch (ScriptRuntimeException ex) {
                Debug.LogError("[Initialize] Could not read script: "
                               + ex.DecoratedMessage);
            } catch (SyntaxErrorException ex) {
                Debug.LogError("[Initialize] Could not read script: "
                               + ex.DecoratedMessage);
            }
        }
        else
        {
            Debug.LogError("The specified script file <" + scriptPath
                           + "> doesn't exist.");
        }
    }