示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LuaScript"/> class.
        /// </summary>
        /// <param name="modules">Lua core modules.</param>
        public LuaScript(CoreModules modules)
        {
            _script = new Script(modules);
            Factory = new LuaClassFactory();
            Set("_factory", Factory);

            //TODO: Store it in database.
            Execute(@"
			function new(className, ...)
				return _factory.New(className, ...)
			end

			function static(className)
				return _factory.Static(className);
			end

			function using(namespace)
				return _factory.AddNamespace(namespace);
			end

			function typenameof(object)
				local type = type(object);
				return type == 'userdata' and object.getCLRType().FullName or type
			end

			function foreach(collection, action)
				for i = 0, collection.Count - 1 do
					action(collection[i]);
				end
			end"            );
        }
示例#2
0
    public static void RegisterWrapper(bool isUpdate)
    {
        //Debug.Log("RegisterWrapper begin");
        LuaState lua_ = LuaInstance.instance.Get();

        if (isUpdate)
        {
            LuaNTools.RegisterToLua(lua_, typeof(LuaNTools));
        }
        else
        {
            LuaVector3.RegisterToLua(lua_, typeof(LuaVector3));
            LuaQuaternion.RegisterToLua(lua_, typeof(LuaQuaternion));
            LuaColor.RegisterToLua(lua_, typeof(LuaColor));
            LuaNTools.RegisterToLua(lua_, typeof(LuaNTools));
            LuaNetwork.RegisterToLua(lua_, typeof(LuaNetwork));
            LuaLong.RegisterToLua(lua_, typeof(LuaLong));
            LuaDateTime.RegisterToLua(lua_, typeof(LuaDateTime));
            LuaUtil.RegisterToLua(lua_, typeof(LuaUtil));
            LuaClassFactory.RegisterToLua(lua_, typeof(LuaClassFactory));
        }

        //Debug.Log("RegisterWrapper end");
    }