Making my own @a/@p/@r arguments, or making my own TestFor command.

Discussion in 'Plugin Development' started by Chris32, Apr 10, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Chris32

    Hey everyone. Looking for help on a concept here. Is it possible for me to create my own arguments for TestFor such as
    Code:
    /testfor @p[my_custom_argument=1]
    or
    Code:
    /tp @a[my_custom_argument=1]
    . Another possible thing I could do to solve my problem is make a new TestFor command. Can you help me?

    Thanks in advance.
     
  2. So those are just subcommands or arguments that can be used in any order ?

    If they're order-less arguments you should basically loop through the args and check for @ at char 0 and make a switch() for char 1, then you just use .substring() to remove the prefix from the value, then split it by = and parse accordingly.
     
    Chris32 likes this.
  3. Offline

    Chris32

    Kind of. As you probably know, commands can now have arguments, such as...
    Code:
    /tp @a[x=100,y=100,z=100,r=10] 100 100 100
    That command looks through all players and teleports any that are within 10 blocks of 100 100 100 and teleports them to 100 100 100. I'd like to add an argument, like so:
    Code:
    /tp @a[x=100,y=100,z=100,r=10,crouched=1] 100 100 100
    That could theoretically tp anyone that's crouching (along with the previously mentioned arguments) to 100 100 100. Sorry if my original post was a bit vague. Is there any easier way to do this?

    Another possibility I think would be to add a new command and activate any redstone around it when it's used in a command block. Here's some psuedocode:
    Code:
    WHEN COMMAND /CROUCHING @p IS USED
        IF PLAYER @p IS CROUCHING AND THIS IS A COMMAND BLOCK
            ACTIVATE REDSTONE NORTH/EAST/WEST/SOUTH OF THIS COMMAND BLOCK
            STOP ACTIVATING AFTER 1 TICK
     
  4. Hmm, if this already exists you should look in the CB source and see how they've done it :p
     
Thread Status:
Not open for further replies.

Share This Page