How to use multiargs without using the previous args in the same command line? #266


  • Defect
  • Enhancment
Open
  • itsch4rl1e created this issue Apr 9, 2021

    I have a command for automating the creation of Citizen2 NPCs. I actually have 2 issues but my primary one is that I have formatted my command as such:

    /newstaffnpc [real_player_name] [dislay_name] [holotext]

     

    There's bugs with using NPCs directly named after players so I do this:

     

    new_player_lookalike_npc:
      command: /newstaffnpc
      type: RUN_CONSOLE
      register: true
      permission-error: 'You lack permission for this!'
      error-message: '&cusage: /newnpc [real_player_name] [display_name] [role]. Accepts colour codes in display_name and role.'
      required_args: 3
      tab_completer:
      '1':
      - $player_list
      '2':
      - display_name
      '3':
      - &4Owner
      - &cAdmin
      - &5Moderator
      - &2Builder
      - &fMember
      runcmd:
      - '/npc create $arg1_NPC --at $locX:$locY:$locZ:$world'
      - '/npc name'
      - '/npc nickname --set $arg2'
      - '/npc skin $arg1 -l'
      - '/text name $arg2'
      - $Script$%TempVariable%holotext=$
      - '/npc hologram add $arg3'
      - '/npc hologram add $arg2'
      - '/npc hologram lineheight 0.3'

    My problem is on the line "'/npc hologram add $arg3'" I'd like to be able to say *anything* on that final line, e.g. stuff with spaces like "Click me".

     

    Now, I could do that manually but I'd like to include it as part of the automated process. However, swapping "$arg3" for "$multiargs" doesn't work, it takes the entire command string and shoves it in there instead. e.g. the command "/newstaffcommand MyRealName Trader Click me!" produces - in the instance that I have $multiargs" instead of $arg3 on the line noted above - an NPC with the hologram text "MyRealName Trader Click me!", instead of just "Click me!" 

    I tried wrapping it in quotes instead and just using $arg3 but this didn't help either, it threw an error and set the text to `"Click".

     

    Anyway this highlights a general issue that I can't find a way to use all the arguments *past* a specific argument without using those arguments on the same command input line as suggested in the docs. E.g. "args1 $multiargs" would eliminate the first argument then dump the rest into $multiargs, but I want this behaviour without having to first make use of the previous arguments. 

     

    My secondary issue is that the tab_completer just doesn't work for the above command definition, it shows the player list for every argument instead of what I asked for. 

  • itsch4rl1e added the tags Defect Enhancment Apr 9, 2021
  • itsch4rl1e edited description Apr 9, 2021
  • ivanfromitaly posted a comment Apr 23, 2021

    It should be automatic, but it was half broken.

    I've remade the auto "check" (5.7.1), now it replace multiargs with only the arguments typed in after the highest $arg found on that line. So you always need atleast one $arg1,2,3 ecc per line, and then put $multiargs.

    The tab_completer works if formatted correctly, but i've had to remvoe the color codes from the rank groups. I guess you can exempt the colorcorse from being replaced with the specific feature.

     

     

  • itsch4rl1e posted a comment May 16, 2021

    My problem was, I need $multiargs to contain say $args 4,5,6....etc. but not args1,2,3. I can't use $args1,2,3 on the same line as the command I am invoking does not use them. Unless there is a way to run multiple commands in one line that I have missed. 


To post a comment, please login or register a new account.