// create a new LuaObject using the given state and stack index.
func NewLuaObject(L *lua.State, idx int) *LuaObject {
	tp := lua.LTypename(L, idx)
	L.PushValue(idx)
	ref := L.Ref(lua.LUA_REGISTRYINDEX)
	return &LuaObject{L, ref, tp}
}