示例#1
0
 /// <summary>
 /// Sets a field of a lua table to a lua variable identified by luaIdentifier i.e. luaTable.someField = luaVariable
 /// The table to operate on must currently be on top of the lua stack.
 /// After the call the lua table is still on top of the stack.
 /// </summary>
 /// <param name="fieldName">name of the field</param>
 /// <param name="luaIdentifier">the identifier identifying the lua variable</param>
 public void SetTableFieldToLuaIdentifier(string fieldName, string luaIdentifier)
 {
     Lua.lua_pushstring(L, fieldName);
     Lua.lua_getglobal(L, luaIdentifier);
     Lua.lua_settable(L, -3);
     //table is still on top of the stack
 }
示例#2
0
 /// <summary>
 /// Sets a field of a lua table to a lua variable identified by luaIdentifier i.e. luaTable.someField = luaVariable
 /// After the call the lua stack is balanced.
 /// </summary>
 /// <param name="tableName">name of the lua table</param>
 /// <param name="fieldName">name of the field</param>
 /// <param name="luaIdentifier">the identifier identifying the lua variable</param>
 public void SetTableFieldToLuaIdentifier(string tableName, string fieldName, string luaIdentifier)
 {
     Lua.lua_getglobal(L, tableName);
     Lua.lua_pushstring(L, fieldName);
     Lua.lua_getglobal(L, luaIdentifier);
     Lua.lua_settable(L, -3);
     Lua.lua_pop(L, 1);
     //stack is balanced
 }
示例#3
0
        /// <summary>
        /// Sets a field of a lua table to a .net variable value i.e. luaTable.someField = value of .net variable.
        /// After the call the lua table is still on top of the stack.
        /// </summary>
        /// <param name="fieldName">name of the field</param>
        /// <param name="value">.net variable</param>
        public void SetTableField(string fieldName, object value)
        {
            if (IsTopNil)
            {
                throw new Exception("SetTableField, no table on top of the stack");
            }

            //push table field name on the stack
            Lua.lua_pushstring(L, fieldName);

            //push value on the stack
            PushBasicValue(value);

            //set field of table to value: tableName[fieldName]=value
            Lua.lua_settable(L, -3);

            //table is still on top of the stack
        }
示例#4
0
        /// <summary>
        /// Sets a field of a lua table to a .net variable value i.e. luaTable.someField = value of .net variable.
        /// After the call the lua stack is balanced.
        /// </summary>
        /// <param name="tableName">name of the lua table</param>
        /// <param name="fieldName">name of the field</param>
        /// <param name="value">.net variable</param>
        public void SetTableField(string tableName, string fieldName, object value)
        {
            //push table on the stack
            Lua.lua_getglobal(L, tableName);

            if (IsTopNil)
            {
                throw new Exception("SetTableField, the table does not exist: " + tableName);
            }

            //push table field name on the stack
            Lua.lua_pushstring(L, fieldName);

            //push value on the stack
            PushBasicValue(value);

            //set field of table to value: tableName[fieldName]=value
            Lua.lua_settable(L, -3);
            //pop table of the stack
            Lua.lua_pop(L, 1);
            //stack is balanced
        }