Example #1
0
        static void SetBlock(Player p, BlockProps[] scope, BlockID block,
                             string msg, string type, ref BlockID target)
        {
            string name = BlockProps.ScopedName(scope, p, block);

            if (msg.Length == 0)
            {
                target = Block.Invalid;
                p.Message("{1} for {0} removed.", name, type);
            }
            else
            {
                BlockID other;
                if (!CommandParser.GetBlockIfAllowed(p, msg, "use", out other))
                {
                    return;
                }
                if (other == block)
                {
                    p.Message("ID of {0} must be different.", type); return;
                }

                target = other;
                p.Message("{2} for {0} set to: {1}",
                          name, BlockProps.ScopedName(scope, p, other), type);
            }
        }
Example #2
0
        static void SetStackId(Player p, BlockProps[] scope, BlockID block, string msg)
        {
            BlockID stackBlock;

            if (msg.Length == 0)
            {
                stackBlock = Block.Air;
            }
            else
            {
                if (!CommandParser.GetBlock(p, msg, out stackBlock))
                {
                    return;
                }
            }
            scope[block].StackBlock = stackBlock;

            string name = BlockProps.ScopedName(scope, p, block);

            if (stackBlock == Block.Air)
            {
                p.Message("Removed stack block for {0}", name);
            }
            else
            {
                p.Message("Stack block for {0} set to: {1}",
                          name, BlockProps.ScopedName(scope, p, stackBlock));
            }
        }
Example #3
0
        static void Toggle(Player p, BlockProps[] scope, BlockID block, string type, ref bool on)
        {
            on = !on;
            string name = BlockProps.ScopedName(scope, p, block);

            p.Message("Block {0} is {1}: {2}", name, type, on ? "&aYes" : "&cNo");
        }
Example #4
0
 static void SetAI(Player p, BlockProps[] scope, BlockID block, string msg) {
     AnimalAI ai = AnimalAI.None;
     if (!CommandParser.GetEnum(p, msg, "Animal AI", ref ai)) return;
     scope[block].AnimalAI = ai;
     
     string name = BlockProps.ScopedName(scope, p, block);
     p.Message("Animal AI for {0} set to: {1}", name, ai);
 }
Example #5
0
 static void SetDeathMsg(Player p, BlockProps[] scope, BlockID block, string msg) {
     string name = BlockProps.ScopedName(scope, p, block);
     if (msg.Length == 0) {
         scope[block].DeathMessage = null;
         p.Message("Death message for {0} removed.", name);
     } else {
         scope[block].DeathMessage = msg;
         p.Message("Death message for {0} set to: {1}", name, msg);
     }
 }
Example #6
0
 static void ToggleBehaviour(Player p, BlockProps[] scope, BlockID block, string type, ref bool on) {
     string behaviour;
     // Check if this would make a block both a door and a portal for instance
     // If blocks have multiple behaviour, this would confuse users because only 1 behaviour works
     if (!on && (behaviour = CheckBehaviour(scope, block)) != null) {
         string name = BlockProps.ScopedName(scope, p, block);
         p.Message("&WBlock {0} cannot be made {1}, is it already a {2}", name, type, behaviour);
         return;
     }         
     Toggle(p, scope, block, type, ref on);
 }