Example #1
0
        public override void Action(CommandCaller player, string input, string[] args)
        {
            //try{
            string     itemName;
            ActionItem item;
            string     literal;

            ActionContext.Default.Caster = player.Player;
            for (int i = 0; i < args.Length; i++)
            {
                mod.Logger.Info($"parsing \'{args[i]}\'");
                itemName = args[i].Split('.')[0];
                item     = Jailbreak.GetAction(itemName);
                if (item.hasLiteral)
                {
                    literal = args[i].Substring(itemName.Length + 1);
                    item    = Jailbreak.CreateNew(item);
                    item.ApplyLiteral(literal);
                    mod.Logger.Info($"set literal of {item} to {literal}");
                }
                ActionContext.Default.lastReturn = item.Execute(0) ?? ActionContext.Default.lastReturn;
            }

            /*}catch (Exception e){
             *  Main.NewText(e.Message);
             * }*/
        }
Example #2
0
        public override void Action(CommandCaller player, string input, string[] args)
        {
            //try{
            string     itemName;
            ActionItem item;
            string     literal;

            ActionContext.Default.Caster = player.Player;
            int i = 0;

            if (args[0] == "+=")
            {
                i++;
            }
            else
            {
                TestItem.actions = new List <ActionItem>()
                {
                };
            }

            for (; i < args.Length; i++)
            {
                mod.Logger.Info($"parsing \'{args[i]}\'");
                itemName = args[i].Split('.')[0];
                item     = Jailbreak.GetAction(itemName);
                if (item.hasLiteral)
                {
                    literal = args[i].Substring(itemName.Length + 1);
                    item    = Jailbreak.CreateNew(item);
                    item.ApplyLiteral(literal);
                    mod.Logger.Info($"set literal of {item} to {literal}");
                }
                TestItem.actions.Add(item);
            }

            /*}catch (Exception e){
             *  Main.NewText(e.Message);
             * }*/
        }
Example #3
0
        public override void OnInitialize()
        {
            int l = 1;

            if (drive != null)
            {
                if (drive.Actions == null)
                {
                    drive.Actions = new List <ActionItem>()
                    {
                    }
                }
                ;
                l += drive.Actions.Count;
            }
            if (maxSize > 0 && l > maxSize)
            {
                l = maxSize;
            }
            Main.UIScaleMatrix.Decompose(out Vector3 scale, out Quaternion ignore, out Vector3 ignore2);
            ActionItem current;
            int        layers = 0;
            int        xPos   = 0;

            for (int i = 0; i < l; i++)
            {
                currIndex = i;
                if (drive.Readonly && drive.Actions.Count <= i)
                {
                    break;
                }
                if (i >= itemSlots.Count)
                {
                    itemSlots.Add(null);
                }
                current      = drive.Actions.Count > i?drive.Actions[i]:null;
                itemSlots[i] = new GlyphItemSlot(scale: 0.75f, context: drive.Readonly ? ItemSlot.Context.CraftingMaterial : ItemSlot.Context.InventoryItem,
                                                 colorContext: drive.Readonly ? ItemSlot.Context.TrashItem : ItemSlot.Context.CraftingMaterial)
                {
                    Left          = { Pixels = (float)((Main.screenWidth * 0.05) + (xPos++ *40 * scale.X)) },
                    Top           = { Pixels = (float)((Main.screenHeight * 0.4) + (layers * 40 * scale.Y)) },
                    ValidItemFunc = item => item.IsAir || (!item.IsAir && (item.modItem is ActionItem)),
                    index         = i
                };
                if (xPos * 40 * scale.X > Main.screenWidth * 0.4)
                {
                    xPos = 0;
                    layers++;
                }
                if (drive != null)
                {
                    if (current != null)
                    {
                        itemSlots[i].item = current?.item ?? Jailbreak.CreateNew(current).item;
                    }
                }
                Append(itemSlots[i]);
                if (current == null)
                {
                    break;
                }
            }
        }