4

I've got a Realms server, and I'm trying to create a series of quests that people can complete to up their overall "Defender of the Realm" score. However, I only want them to be able complete each quest only once.

I check a quest specific score variable for 0 to "start" them on their quest, e.g. @p[score_quest_a=0]. Each step of the quest adds 1 to this variable and it's how I determine the logic for the quest progression. This ensures that once you get to "step 3" or whatever the final step is, the system knows you've completed it and you can't start the quest again.

Here's the problem: the selector @p[score_quest_a=0] doesn't work unless someone has had their quest_a score explicitly set to 0. I need to do that check before setting the variable or else I risk blowing out their quest progress (someone with a quest_a score of 2 pressing the starting button would get their progress reset to 0). Is there a way to say "if quest_a score is not set or is set to 0"?

Here's the full set of commands I'm using (for reference):

/tell @p[r=4,score_medical_quest=0] A ship carrying medical supplies crashed just west of the castle... bring back the supplies and you will be rewarded! 
/tell @p[r=5,score_medical_quest=1,score_medical_quest_min=1] Hurry! People are sick and need those supplies! 
/tell @p[r=6,score_medical_quest=2,score_medical_quest_min=2] Thank you! Here are some diamonds for your troubles! (FYI: quest score set to 2 at quest completion point) 
[ REPEATER ]
/scoreboard players set
@p[r=10,score_medical_quest=0] medical_quest 1 
/give @p[r=8,score_medical_quest=2,score_medical_quest_min=2] diamond 3
[ REPEATER ] 
/scoreboard players add @p[r=9,score_medical_quest=2,score_medical_quest_min=2] global_quests 1 
[ REPEATER ] 
/scoreboard players set @p[r=9,score_medical_quest=2,score_medical_quest_min=2] medical_quest 3 
/tell @p[r=9,score_medical_quest_min=3]

Thanks again for your help, the people are in your debt!

5
+100

I solved the problem with the following code:

scoreboard players add @a quest_a 0

I put this as the first command block in each quest series. Basically, it sets all online players with no quest score to 0, but doesn't effect anyone with an existing score. I don't need to run it on a clock because the block gets triggered and sets a 0 before any tests happen. After that, the test for 0 works properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.