public static void SetUDMFField(MapElement element, string key, DynValue value)
        {
            if (!General.Map.FormatInterface.HasCustomFields)
            {
                ScriptContext.context.WarnFormatIncompatible("UDMF fields not supported.");
                return;
            }

            if (key == null)
            {
                throw new ScriptRuntimeException("key is nil, can't SetUDMFField() (not enough arguments maybe?)");
            }
            if (element == null)
            {
                throw new ScriptRuntimeException("map element is nil, can't SetUDMFField()");
            }
            if (element.IsDisposed)
            {
                throw new ScriptRuntimeException("map element is disposed, can't SetUDMFField()");
            }

            if (value.IsNilOrNan() || value.IsVoid())
            {
                throw new ScriptRuntimeException("value is nil, nan, or void. can't SetUDMFField() (not enough arguments maybe?) " + value.ToObject().GetType().ToString());
            }

            key = UniValue.ValidateName(key);

            if (key == "")
            {
                return;
            }

            object v_object = value.ToObject();

            if (v_object is double)
            {
                v_object = (float)((double)v_object);
            }

            try
            {
                element.SetField(key, v_object);
            }
            catch (ArgumentException)
            {
                throw new ScriptRuntimeException("error setting UDMF field " + key + ", must be int, float, string, double or bool, instead was " + v_object.GetType().ToString());
            }
        }