Carpet

Carpet

2M Downloads

[Scarpet] Can't choose default argument type in custom arguments

altrisi opened this issue ยท 3 comments

commented

When specifying a custom argument for Scarpet, there is no type (that I've found) that equals to the default argument type (that is, an undefined argument).

For instance, the default argument type is a single "word" (that you can only add spaces if using single quotes), that, with those quotes, can accept the # parameter at the start (and basically anywhere). There is no type allowing that character while keeping it still a single "word", and not until the end of the command.

That prevents adding custom options, suggesters or suggestions to those.

(my use case here is was an RGB color input).

Maybe more precisely, default argument type doesn't behave the same as string type.

Carpet 1.4.21

commented

hmm, what that default / empty type would be. It needs to be something, right? Thought 'term' or 'string' are good basis of something fundamental. Please elaborate.

Also - I am all for expanding the list of built-in types more than the default list of arguments provided with brigadier or mc itself. Maybe there should be a more generic type of an input that follow a regex for example.

commented

Oh, by default I meant the one that Carpet uses when its not configured.

For example, given this config:

__config() -> {
  'commands' -> {
    ... 
    'config <config> <value>' -> 'setConfig'
  },
  'arguments' -> {
    'config' -> {
      'type' -> 'term',
      'options' -> keys(global_configs)
    },
  }
);

Since <value> is not defined anywhere, Carpet will just assign it that "default" argument (which is the same as the old legacy argument, but with suggestions), which is a string without spaces, that can accept those with single quotes. It can also accept the # symbol if using those quotes.

If you try to configure that argument, ending with something like the following:

__config() -> {
  'commands' -> {
    ... 
    'config <config> <value>' -> 'setConfig'
  },
  'arguments' -> {
    'config' -> {
      'type' -> 'term',
      'options' -> keys(global_configs)
    },
    'value' -> {
      'type' -> 'string', <<< HERE
      'suggester' -> _(args) -> (
        call(global_configs:(args:'config'), lower(if(args:'value', args:'value', '')));
      )
    }
  }
);

You can't find any type that would mimic the behaviour of that "default" argument type. For instance, using string won't accept # even inside quotes, term IIRC won't accept quotes at all, and the others are already multi-word.

I know in this specific case I can use a multi-word type since it's the end of the command, but this is just an example

commented

can't replicate it anymore. the default argument is the same as 'string'