7

This is my first attempt at using scoreboards for accomplishing tasks so I'm still learning. I'm trying to make a golden helmet behave as night vision goggles by giving the player the night vision effect.

Here's what I've done so far:

  1. Create a dummy objective named "nightVision".
  2. Place this command in a clock:

    scoreboard players set @a nightVision 0

  3. Then this command:

    scoreboard players set @a nightVision 1 {Inventory:[{Slot:103b,tag:{display:{Name:"Nightvision Goggles",Lore:[Equip to see in the dark!]}}}]}

  4. And finally this command:

    effect @a[score_nightVision_min:1] 16 30 0 true

I've tested it by wearing the helmet mentioned above on my head and doing a scoreboard test command. It works if I combine steps 3 and 4 into one testfor command and run a comparator out of it:

testfor [player] {Inventory:[{Slot:103b,tag:{display:{Name:"Nightvision Goggles",Lore:[Equip to see in the dark!]}}}]}

But that seems like the very thing scoreboards could be used to avoid.

I've tried taking out the first command because I thought maybe the scores were being reset too fast but it still doesn't work. I've come to the conclusion that my error is either in step 3 or step 4 but I'm not seeing it.

  • You say you have a clock running, are you certain it's running? – ydobonebi Jul 29 '15 at 0:06
  • Yes. I can run "scoreboard players test" on myself and see that the score for nightVision is 1 when I'm wearing the helmet and 0 when I'm not. The only place those are changed are on that clock. – twicedouble Jul 29 '15 at 0:35
  • 1
    Are you sure that the order the commands are running in is correct? Because the reset command has to be after the others – pangeacake Jul 29 '15 at 4:59
  • 5
    There is an error in step 4, where you use a colon in the target selector instead of an equals sign. Is that just a typo? If not, change it to score_nightVision_min=1 – MrLemon Jul 29 '15 at 12:18
  • I got it working. I believe it was a combination of what PangeaCake suggested as well as the error in syntax that MrLemon pointed out. Thank you! – twicedouble Jul 30 '15 at 5:55
3

As MrLemon has pointed out in the comments, there is an error in your fourth step, where the command is:

effect @a[score_nightVision_min:1] 16 30 0 true

You have to replace the colon ( : ) with an equals sign ( = ) for that part to work.

  • Additionally I also had the commands executing in the wrong order. Silly me. – twicedouble Jul 30 '15 at 5:56

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.