Example #1
0
        public LuaValue this[LuaRuntime runtime, LuaValue key]
        {
            get
            {
                switch (key.ToString())
                {
                case "Length": return(Length);

                case "Range": TextNotificationsManager.Debug("WDist.Range is deprecated. Use WDist.Length instead"); return(Length);

                default: throw new LuaException($"WDist does not define a member '{key}'");
                }
            }

            set => throw new LuaException("WDist is read-only. Use WDist.New to create a new value");
Example #2
0
        static void TakeScreenshotInner()
        {
            using (new PerfTimer("Renderer.SaveScreenshot"))
            {
                var mod       = ModData.Manifest.Metadata;
                var directory = Path.Combine(Platform.SupportDir, "Screenshots", ModData.Manifest.Id, mod.Version);
                Directory.CreateDirectory(directory);

                var filename = TimestampedFilename(true);
                var path     = Path.Combine(directory, string.Concat(filename, ".png"));
                Log.Write("debug", "Taking screenshot " + path);

                Renderer.SaveScreenshot(path);
                TextNotificationsManager.Debug("Saved screenshot " + filename);
            }
        }
Example #3
0
        public LuaValue Subtract(LuaRuntime runtime, LuaValue left, LuaValue right)
        {
            if (!left.TryGetClrValue(out WAngle a))
            {
                throw new LuaException($"Attempted to call WAngle.Subtract(WAngle, WAngle) with invalid arguments ({left.WrappedClrType().Name}, {right.WrappedClrType().Name})");
            }

            if (right.TryGetClrValue(out int c))
            {
                TextNotificationsManager.Debug("Support for facing calculations mixing Angle with integers is deprecated. Make sure all facing calculations use Angle");
                return(new LuaCustomClrObject(a - FromFacing(c)));
            }

            if (right.TryGetClrValue(out WAngle b))
            {
                return(new LuaCustomClrObject(a - b));
            }

            throw new LuaException($"Attempted to call WAngle.Subtract(WAngle, WAngle) with invalid arguments ({left.WrappedClrType().Name}, {right.WrappedClrType().Name})");
        }