Example #1
0
        public void SetColour(byte index, byte r, byte g, byte b)
        {
            if (index < 1 || index > 8)
            {
                throw ScriptRuntimeException.BadArgumentIndexOutOfRange("SetColour", 0);
            }

            if (r > 0x0F)
            {
                throw ScriptRuntimeException.BadArgument(1, "SetColour", "value is out of range (range is 0x0-0xF)");
            }

            if (g > 0x0F)
            {
                throw ScriptRuntimeException.BadArgument(2, "SetColour", "value is out of range (range is 0x0-0xF)");
            }

            if (b > 0x0F)
            {
                throw ScriptRuntimeException.BadArgument(3, "SetColour", "value is out of range (range is 0x0-0xF)");
            }

            if (!_lighting.SetColour(index, Color.FromRgb(r, g, b)))
            {
                throw new ScriptRuntimeException("rip");
            }
        }
Example #2
0
        public void SetStepDuration(ushort stepDuration)
        {
            if (stepDuration > Lighting.STEP_DURATION_MAX_VALUE)
            {
                throw ScriptRuntimeException.BadArgumentIndexOutOfRange("SetStepDuration", 0);
            }

            _lighting.SetStepDuration(stepDuration);
        }
Example #3
0
        public void SetFlashingSpeed(byte flashingSpeed)
        {
            if (!Enum.IsDefined(typeof(Lighting.FlashingSpeed), flashingSpeed))
            {
                throw ScriptRuntimeException.BadArgumentIndexOutOfRange("SetFlashingSpeed", 0);
            }

            _lighting.SetFlashingSpeed((Lighting.FlashingSpeed)flashingSpeed);
        }
Example #4
0
        public DynValue GetColour(byte index)
        {
            if (index < 1 || index > 8)
            {
                throw ScriptRuntimeException.BadArgumentIndexOutOfRange("GetColour", 0);
            }

            Color c = _lighting.GetColour(index).Value;

            return(DynValue.NewTuple(new DynValue[]
            {
                DynValue.NewNumber(c.R),
                DynValue.NewNumber(c.G),
                DynValue.NewNumber(c.B)
            }));
        }
Example #5
0
        public static DynValue select(ScriptExecutionContext executionContext, CallbackArguments args)
        {
            if (args[0].Type == DataType.String && args[0].String == "#")
            {
                if (args[args.Count - 1].Type == DataType.Tuple)
                {
                    return(DynValue.NewNumber(args.Count - 1 + args[args.Count - 1].Tuple.Length));
                }
                else
                {
                    return(DynValue.NewNumber(args.Count - 1));
                }
            }

            DynValue v_num = args.AsType(0, "select", DataType.Number, false);
            int      num   = (int)v_num.Number;

            List <DynValue> values = new List <DynValue>();

            if (num > 0)
            {
                for (int i = num; i < args.Count; i++)
                {
                    values.Add(args[i]);
                }
            }
            else if (num < 0)
            {
                num = args.Count + num;

                if (num < 1)
                {
                    throw ScriptRuntimeException.BadArgumentIndexOutOfRange("select", 0);
                }

                for (int i = num; i < args.Count; i++)
                {
                    values.Add(args[i]);
                }
            }
            else
            {
                throw ScriptRuntimeException.BadArgumentIndexOutOfRange("select", 0);
            }

            return(DynValue.NewTupleNested(values.ToArray()));
        }