/// <summary> /// Gets or sets the global with the given name. /// </summary> /// <param name="name">The name.</param> /// <returns>The value of the global.</returns> /// <exception cref="ArgumentException"> /// <paramref name="value"/> is a <see cref="LuaReference"/> which is tied to a different <see cref="Lua"/> environment. /// </exception> /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> /// <exception cref="ObjectDisposedException">The <see cref="Lua"/> environment is disposed.</exception> public object this[string name] { get { if (name == null) { throw new ArgumentNullException(nameof(name)); } ThrowIfDisposed(); var type = LuaApi.GetGlobal(MainState, name); var result = ToObject(-1, type); LuaApi.Pop(MainState, 1); return(result); } set { if (name == null) { throw new ArgumentNullException(nameof(name)); } ThrowIfDisposed(); PushObject(value); LuaApi.SetGlobal(MainState, name); } }