luaobject.go
func (lo *LuaObject) Set(a interface{}, subfields ...interface{}) error {
	parentKeys := subfields[:len(subfields)-1]
	parent, err := lo.GetObject(parentKeys...)
	if err != nil {
		return err
	}

	L := parent.l
	parent.Push()
	defer L.Pop(1)

	lastField := subfields[len(subfields)-1]
	if L.IsTable(-1) {
		GoToLuaProxy(L, lastField)
		GoToLuaProxy(L, a)
		L.SetTable(-3)
	} else if L.GetMetaField(-1, "__newindex") {
		L.PushValue(-2)
		GoToLuaProxy(L, lastField)
		GoToLuaProxy(L, a)
		err := L.Call(3, 0)
		if err != nil {
			L.Pop(1)
			return err
		}
	} else {
		return ErrLuaObjectIndexable
	}
	return nil
}
func (lo *LuaObject) Set(a interface{}, subfields ...interface{}) error {
	parentKeys := subfields[:len(subfields)-1]
	parent, err := lo.GetObject(parentKeys...)
	if err != nil {
		return err
	}

	L := parent.l
	parent.Push()
	defer L.Pop(1)

	lastField := subfields[len(subfields)-1]
	if L.IsTable(-1) {
		GoToLuaProxy(L, lastField)
		GoToLuaProxy(L, a)
		L.SetTable(-3)
	} else if L.GetMetaField(-1, "__newindex") {
		L.PushValue(-2)
		GoToLuaProxy(L, lastField)
		GoToLuaProxy(L, a)
		err := L.Call(3, 0)
		if err != nil {
			L.Pop(1)
			return err
		}
	} else {
		return ErrLuaObjectIndexable
	}
	return nil
}
func ( lo * LuaObject ) Set ( a interface { } , subfields ... interface { } ) error { parentKeys := subfields [ : len ( subfields ) - 1 ] parent , err := lo . GetObject ( parentKeys ... ) if err != nil { return err } L := parent . l parent . Push ( ) defer L . Pop ( 1 ) lastField := subfields [ len ( subfields ) - 1 ] if L . IsTable ( - 1 ) { GoToLuaProxy ( L , lastField ) GoToLuaProxy ( L , a ) L . SetTable ( - 3 ) } else if L . GetMetaField ( - 1 , " " ) { L . PushValue ( - 2 ) GoToLuaProxy ( L , lastField ) GoToLuaProxy ( L , a ) err := L . Call ( 3 , 0 ) if err != nil { L . Pop ( 1 ) return err } } else { return ErrLuaObjectIndexable } return nil }
// Set sets the value at the sequence of 'subfields' with the value 'a'.
// Numeric indices start from 1, as in Lua: if we started from zero, access to
// index 0 or negative indices would be shifted awkwardly.
Set sets the value at the sequence of subfields with the value a . Numeric indices start from 1 as in Lua : if we started from zero access to index 0 or negative indices would be shifted awkwardly .