Add support for %TempVariable% in %TempVariable% #280

  • Enhancment
  • OwnMakesChannel created this issue May 12, 2021

    I am using the Quests Plugin and the PAPI Placeholder. I want to add the name of the quest at just one spot and then the name of the %TempVariable% everywhere else like here.


    - '%TempVariable%quest1=Die erste Prufung'
    - '%TempVariable%test1=%quests_player_can_accept_quest_quest1%'


    - '$text$test1' #is not working, returns false, because it recognizes %quests_player_can_accept_quest_quest1%

    - '$text$%quests_player_can_accept_quest_quest1%' #works, returns true, recognizes %quests_player_can_accept_quest_Die erste Prufung%


  • OwnMakesChannel added a tag Enhancment May 12, 2021
  • ivanfromitaly posted a comment May 13, 2021

     I've added a way to specifically make this possible to work. just use [Replace] as a prefix of the second variable, example :


    - '%TempVariable%$pname=$player'
    - '%TempVariable%$test4=[Replace]%player_ping_$pname%'
    - '$text$ 4 = $test4 '

     If you want test it : Link Removed:



    Edited May 13, 2021
  • OwnMakesChannel posted a comment May 13, 2021

    Didn't know, I will try, if I need, because it works somehow without it now. I even use it with a PAPI Placeholder and an $arg in a recursive function:


    - '%TempVariable%quest1=Die erste Prufung'

    - '%TempVariable%toCheckFirst=%quests_player_meets_requirements_to_start_quest$arg3%'




    I tried the [Replace] and it doesn't work at all. It just makes it worse, because it is not getting translatet in your 3 lines of code (I tried your example).


    I try to use this code:


    - '%TempVariable%$questName=Die erste Prufung'

    - '%TempVariable%toCheckThird=[Replace]$questName'

    - '$text$toCheckThird'


    It prints: [Replace]questName




    Edited May 13, 2021
  • ivanfromitaly posted a comment May 13, 2021

    Are you using the version of the plugin posted here? Because it's stuff i've added today.


    On the 5.7.1 it's impossible that work this line '%TempVariable%test1=%quests_player_can_accept_quest_quest1%' Because the replace process was done before. PAPI pass there and find anything, or replace his placeholder with whatever is written into it. But not, the content of the tempvar. %.._quest1% pass as %..._quest1% and not as %..._CONTENT%, idk if you have understand.


    In the 5.7.2dev posted above doing [Replace] as my example, you can replace first "quest1" with the tempvar, and then all the remaining stuff.



    Edited May 13, 2021
  • OwnMakesChannel posted a comment May 14, 2021

     Omg, big thanks. I didn't get that you posted a new Version there for download. Now it works fine and it saved me code of 2 days, because it worked just for the first one somehow and just in that case there. But the other commands from PAPI that I use are working without the [Replace] somehow.


    This works for me on the new Dev Version or actually the $text$ output is right:

    - '%TempVariable%toCheckFirst=%quests_player_meets_requirements_to_start_quest$arg3%'
    - '%TempVariable%toCheckSecond=%quests_player_has_completed_quest_quest$arg3%'
    - '%TempVariable%toCheckThird=[Replace]%quests_player_has_current_quest_quest$arg3%'


    Not it returns the right values, but the "'$Script$%if%" works not every time somehow. It's differently and works sometimes for "toCheckFirst" or "toCheckSecond" or on "toCheckThird". Sometimes on two of them and sometimes on all three of them. It also differs from recursive call. On the first one it works every time, on the second not and on the third sometimes again. I already tried to use [Replace] on everyone.


    I am using for testing:

    - '$Script$%if%toCheckThird==Nein' #Nein is false on german on the Quests Plugin for %quests_player_has_current_quest_<quest>%
    - '$text$works1'
    - '$text$'


    Normally I use in the Code a Variable and it works normally, but sometimes it does not even work with the right value (like at the top):

    - '%TempVariable%statusNötigSecond=false'


    - '$Script$%if%toCheckSecond==statusNötigSecond'
    - '$text$works1'
    - '$text$'


    I also tried to insert the exact value in the PAPI Placeholder and it does not work with this either. I assume it's a problem with the %TempVariable% in that the placeholder answer is getting inserted (in this case toCheckFirst):


    - '%TempVariable%toCheckFirst=%quests_player_meets_requirements_to_start_Die erste Prufung%'


    - '$Script$%if%toCheckFirst==true'
    - '$text$works1'
    - '$text$'



    Edited May 14, 2021
  • OwnMakesChannel posted a comment May 15, 2021

    Problem found:


    %TempVariable% is always using the same variable from the first run of the recursion and when I want to give an another value it is still using the old one:


    - '%TempVariable%toCheckFirst=%quests_player_has_current_quest_quest$arg3%' #when it is true, it will be always true, I have to execute the

                                                                                                                                                          #command per hand one more time, so that it can have an 

                                                                                                                                                          #another value


    You can maybe add a hotfix (it is a welcome feature aswell). I tried it like this, but it is not converting the $arg in the right order and I assume that the %TempVariable% has still the Name toCheckFirst$arg3:


    - '%TempVariable%toCheckFirst$arg3=%quests_player_has_current_quest_quest$arg3%' #$arg3 is the counting up and is 1, 2, 3 and so on


    I want to publish a big Quests update on my Minecraft Server for my community, but this is the only problem that is stopping me from that. It would be really nice, if you could bring a fix for that till Tuesday and maybe send me a dev version of the plugin again.



  • ivanfromitaly posted a comment May 16, 2021

    First of all, [Replace] is to be used only if you're including tempvars in the second part of the operation. In all other cases i guess it was working also before, because $args get's replaced before mycmd placeholders or papi.


    On the problem you found, i'm not following you. Can you make an example and what you want as a result? What variable is still using?

    Do an example with the desidered output and what instead happen. Because in this way, i can't help you.

  • OwnMakesChannel posted a comment May 17, 2021

    How do you mean second part of the operation using [Replace]?


    This is the used function, maybe this will help understand my problem. I will explain it a bit more beneath (I included just the necessary parts, green are the necessary comments on english):


    command: /jeffreyHauptQuestNPCCommand
    type: RUN_COMMAND
    #Wie viele Quests da (Laufvariabel für Rekursiv)
    - '%TempVariable%laufvariabel=2' #how many times the function will be repeated (or actually how many quests will be checked)

    #Der Name des NPCs für den Code
    - '%TempVariable%NPCName=jeffrey'

    #Setzt das nicht beim NPC für nicht beim NPC Anzeige
    - '%TempVariable%beimNPC=0'

    #Definieren Quest Vorhanden, damit das nicht undefiniert ist
    - '%TempVariable%questVorhanden=$arg4'

    #grau für Quest Button beim NPC
    - '%TempVariable%buttonFarbe=7'

    #ob Buttons für jede einzelne Quest angezeigt werden
    - '%TempVariable%buttonsAnzeigen=1'

    #Quest Die erste Prüfung  #here is added all the necessary information for the first Quest
    - '%TempVariable%quest1=Die erste Prüfung'
    - '%TempVariable%questWörter1=3'
    - '%TempVariable%questTrennung1=0'
    - '%TempVariable%questLeerzeichenErste1=5'
    - '%TempVariable%questLeerzeichenZweite1=0'


    #Quest Mob_Hunter #here is added all the necessary information for the second Quest
    - '%TempVariable%quest2=Mob_Hunter'
    - '%TempVariable%questWörter2=1'
    - '%TempVariable%questTrennung2=0'
    - '%TempVariable%questLeerzeichenErste2=2'
    - '%TempVariable%questLeerzeichenZweite2=0'

    #Setzt die ifs für Quests beim NPCs #here are set the if variables, that get checked beneath, if the quest buttons should be shown
    - '$Script$%if%$arg2==0'
    - '%TempVariable%toCheckFirst=[Replace]%quests_player_meets_requirements_to_start_quest$arg3%' #$arg3 is the number of times the function

                                                                                                                                                                                              #has been repeated
    - '%TempVariable%toCheckSecond=[Replace]%quests_player_has_completed_quest_quest$arg3%'
    - '%TempVariable%toCheckThird=[Replace]%quests_player_has_current_quest_quest$arg3%'
    - '%TempVariable%statusNötigFirst=true' #the "toCheckFirst" has to be "statusNötigFirst" and so on
    - '%TempVariable%statusNötigSecond=false'
    - '%TempVariable%statusNötigThird=Nein'

    #Setzt die ifs für Quests beim /quests Befehl #there are two cases, one for "you can take the quest" and "you have already taken it, get some more

                                                                                      #info for the quest you do"
    - '$Script$%if%$arg2==1'
    - '%TempVariable%toCheckFirst=%quests_player_has_current_quest_quest$arg3%'
    - '%TempVariable%toCheckSecond=%quests_player_has_current_quest_quest$arg3%'
    - '%TempVariable%toCheckThird=%quests_player_has_current_quest_quest$arg3%'
    - '%TempVariable%statusNötigFirst=Ja'
    - '%TempVariable%statusNötigSecond=Ja'
    - '%TempVariable%statusNötigThird=Ja'

    #wenn Quest-Button nicht angezeigt wird, dann werden einzelne Buttons für Quests angezeigt
    - '$Script$%if%$arg1==1'
    - '%TempVariable%buttonsAnzeigen=0'

    #Der eigentliche Befehl für die Quest Buttons #here is checked, if the quest is available and the Quest buttons should be shown
    - '$Script$%if%toCheckFirst==statusNötigFirst<and>toCheckSecond==statusNötigSecond<and>toCheckThird==statusNötigThird'

    #here on this if is the actual problem, on the first run it functions all perfectly, but on the next ones it does not

    #if the buttons for the first quest out of the first run is shown, all the other quests are shown aswell and if the quest button for the first quest is not

    #shown, all the other buttons are not getting show either, even if for example "toCheckFirst" and "statusNötigFirst" are the same on the second

    #run, when I print them with $text$ (when they are "true" both). When they are the same on the first run, it is always the same and the other way

    #round, it remembers it somehow for all the other runs
    - '/NPCNameHauptQuestNPCQuestVorhandenText $arg1 $arg4 $arg2'
    - '/showQuestButton buttonsAnzeigen $arg2 NPCName questWörter$arg3 questTrennung$arg3 questLeerzeichenErste$arg3 questLeerzeichenZweite$arg3 quest$arg3'
    - '%TempVariable%questVorhanden=1'
    - '%TempVariable%buttonFarbe=6'

    - '$Script$%if%$arg3!=laufvariabel' #here happens the magic, it checks if the function have been repeated enough times
    - '%TempVariable%ubergabeLaufvariabel=$arg3' #if not, it counts up
    - '%TempVariable%ubergabeLaufvariabel+1'
    - '/NPCNameHauptQuestNPCCommand $arg1 $arg2 ubergabeLaufvariabel questVorhanden' #repeats the function and the next quest gets

                                                                                                                                                                              #checked, if the button for it should be shown or not

    permission-required: false
    require_all_arguments: true
    permission-error: "&a$player! , &2You can't use this command!"


    This is how it looks like, if you can take both quests. This function show all of this dynamically, if you can accept or not the quests.


    This is the /quests function, that uses the same function with other given variables to show the taken Quest "Die erste Prüfung". It is then not shown in the previous image anymore.



  • ivanfromitaly posted a comment May 17, 2021

    I don't know where to start, i think the best way is to talk in someway on discord if you want (contact in private) and try to explain better.

    Second thing, you said at the first run is ok, and at the second one the old tempvars are still there? If that's the case i can add something to reset them, if that can help.

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