protected override void Initialized(object state)
        {
            base.Initialized(state);

            if (_ctx != null)
            {
                _ctx.Dispose();
            }

            _ctx = new NLua.Lua();
            _ctx.LoadCLRPackage();

            _ctx.RegisterFunction("AddCommand", this, this.GetType().GetMethod("AddCommand"));
            _ctx.RegisterFunction("ArraySort", this, this.GetType().GetMethod("ArraySort"));
            //_ctx.RegisterFunction("HookBase", this, this.GetType().GetMethods()
            //    .Where(x => x.Name == "HookBase" && x.GetParameters().Last().ParameterType == typeof(NLua.LuaFunction))
            //    .First());

            //Access level enum
            _ctx.NewTable("AccessLevel");
            var ac = _ctx.GetTable("AccessLevel");

            foreach (var val in Enum.GetValues(typeof(TDSM.API.Command.AccessLevel)))
            {
                var al = (TDSM.API.Command.AccessLevel)val;
                ac[al.ToString()] = (int)val;
            }

            _ctx.DoFile(Path);

            CallSelf("Initialized");

            var plg = _ctx["export"] as NLua.LuaTable;

            if (plg != null)
            {
                this.TDSMBuild   = (int)(double)plg["TDSMBuild"];
                this.Author      = plg["Author"] as String;
                this.Description = plg["Description"] as String;
                this.Name        = plg["Name"] as String;
                this.Version     = plg["Version"] as String;

                IsValid = true;

                var hooks = plg["Hooks"] as NLua.LuaTable;
                if (hooks != null)
                {
                    foreach (KeyValuePair <Object, Object> hookTarget in hooks)
                    {
                        var hook      = hookTarget.Key as String;
                        var hookPoint = PluginManager.GetHookPoint(hook);

                        if (hookPoint != null)
                        {
                            var details  = hookTarget.Value as NLua.LuaTable;
                            var priority = (HookOrder)(details["Priority"] ?? HookOrder.NORMAL);
                            //var priority = FindOrder(details["Priority"] as String);

                            var del = _ctx.GetFunction(hookPoint.DelegateType, "export.Hooks." + hook + ".Call");
                            HookBase(hookPoint, priority, del); //TODO maybe fake an actual delegate as this is only used for registering or make a TDSM event info class
                        }
                    }
                }
            }
        }