Change $arg conversion sequence or add a feature for it #284


  • Enhancment
Open
  • OwnMakesChannel created this issue May 16, 2021

    I want to use the "$argX $multiargs" feature for comamnds,  that is currently the sole available. I want to make the "start" $arg dynamic using a TempVariable according to a another $arg like in the code beneath. Maybe add a [Replace] variable like before, if it would normally interfere with other functionalities (marked red).

     

    - '%TempVariable%$test1=6'
    - '%TempVariable%$test1+$arg3'

    - '[Replace]/setAktiveQuestLine3 $arg$test1 $multiargs'

  • OwnMakesChannel added a tag Enhancment May 16, 2021
  • itsch4rl1e posted a comment May 16, 2021

    Are you having the same issue as me, wherein you wish for a command to take many arguments, but some of the commands it runs inside of your command only need the latter few arguments without using the first few arguments? Glad I'm not the only one who wants something like this!

  • ivanfromitaly posted a comment May 17, 2021

    Can't you just make up the value you need in other way? set a tempvar to the argument you need and use it there on the command, without strange gimmicks. Also because implementing that thing it's just redundant and not a good idea implements. Anyway, answer the other discussion you openeed because i don't know what you want.

     

    @itsch4rl1e if you don't need an argument on a specific command, just.... don't use it?  OwnMakesChannel want something different here.

  • OwnMakesChannel posted a comment May 17, 2021

    Sadly is it not possible doing it an another way. I am giving the function 6+ $args. From the 6th $arg there comes the Name of the Quest. I want to divide this Quest Name on to 2 Lines. One of the $args is the word or actually a number at which the Quest name is getting separated. I also use a number that says how many words the Quest titel has, so that I can save it correctly ($argX $multiargs is currently not working and this is a work around)

     

    Example:

    The Quest Name has 4 words: The home is broken

    It has to be separated at the second word: The home

                                                                                   is broken

    I have to save $arg6, $arg7 in line 1 and $arg8, $arg9 in line 2

     

    I want to do it dynamically. The title always starts at $arg6 and then I add the number of words, where it has to be separated and start all the words of line 2 at this $arg and then till the end.

     

    Example:

    - '%TempVariable%$test1=6' #6 is the $arg number where the title starts
    - '%TempVariable%$test1+$arg3' #$arg3 is the number, where the title gets separated

     

    - '[Replace]/setAktiveQuestLine3 $arg$test1 $multiargs' #the function gets the part of the Quest title that will be set for line 2

     

    Now I solved the problem using 111 lines of code, except of 3 lines of code. It is also highly error-prone right now, because I had to use an if for every case (the title can only have up to 6 words right now, so that I don't have to consider to many cases).

     

    This are these 2 lines, where I use it:

     

     

  • itsch4rl1e posted a comment May 17, 2021
     
    No, precisely my issue, that doesn't work.
     
    I wanted to automate creating an NPC that looks like a real player and displays their role on the server. I can run all of the commands one at a time fine, but automating this was problematic due to the behaviour of $multiargs.

    Say my command takes 4 args, the last of which has variable length.
    One of the internal commands uses $args1
    another separately only uses $args2
    this is fine
    But another command might ONLY want to use that last, VARIABLE LENGTH argument which should be given as $multiargs, but that command IS NOT interested in using $args1-3, and in fact cannot use $args 1-3 on the same line without error. Therefore it is impossible to only use that final arg4 (which in reality is arg4,5,6... etc. for however long the final argument was.) 
     
    Quoting myself: 

    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!" 

     

    Unless I am misreading this we're having a similar issue, I want $multiargs to only use say $args4+, without having to use the previous arguments (3-) on that same command line?

     

    see here: https://www.curseforge.com/minecraft/bukkit-plugins/mycommand/issues/266

  • OwnMakesChannel posted a comment May 19, 2021

    I am aware of this limitation an the dev is already working on that problem. Currently you can use this featue with commands. You can try the command "/say $argX $multiargs" and it works. This is why I give a function named /setAktiveQuestLine3 this as a parameter:

     

    - '/setAktiveQuestLine3 $arg$test1 $multiargs'

     

    My request was it to resolve (or how it is named) "$arg$test1" in an another order. I want to divide a line of words in to two lines for example at the second word.

     

    Example:

    This is a long sentence

    This is

    a long sentence

     

    You can give your function a number (for the sentence above it is 4), so that you know how many words are in that sentence. You always know which $arg starts this sentence and so you just have to make a case for every number of words. If there are maximum 4 words, you have 4 ifs. I do it like this currently. It is not beautiful, but it works.

     

    Example:

    if $arg2==1

    sentence = $arg4

     

    if $arg2==2

    sentence = $arg4 $arg5

     

    if $arg2==3

    sentence = $arg4 $arg5 $arg6

     

    if $arg2==4

    sentence = $arg4 $arg5 $arg6 $arg7

     

    /say sentence #it returns "This is a long"


    Edited May 19, 2021

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