How do I set up a scorebord variable to act as a bool and later test for it

I am making a capture the point map in minecraft in which two teams are capturing points. I intended a capture point that switches color every time a redstone pulse is supplied. now i have a problem with the capturing logic. because if the capture point is from team blue and a team blue player would capture it, it would turn to red and vice versa

I need to set up a score board variable that is not displayed in the sidebar. the variable should be called something like "CaptureTeam". the variable is used to indicate which team has captured the point. CaptureTeam = 1 >> blue, CaptureTeam = 0 >> red.

then I need to test the variable every 2 ticks (using a simple clock and a testfor I figured).

I would like to have 10 capture points. at the start I would like to be able to reset them to a specific team. 5 for team red and 5 for team blue.

I already have the redstone set up because I'm pretty good at that, it's just that command blocks are so situation specific(for every situation there are different commands) that I could not realy find anything on the internet.

can anybody help me with the commands for this?

  1. setting up the scoreboard

  2. changing the variable to 1 or 0

  3. testing the state of the variable


First, create the dummy objective:

/scoreboard objectives add CaptureTeam dummy

You can then set a fake player's score on this objective to 1 or 0, one player per capture point. This is also what you should do to reset and change them:

/scoreboard players set CP1 CaptureTeam 1
/scoreboard players set CP2 CaptureTeam 1
...
/scoreboard players set CP10 CaptureTeam 0

For example, to change the score of capture point 6 to blue, you would run:

/scoreboard players set CP6 CaptureTeam 1

Because these aren't real players, /testfor won't work. You should instead use this:

/scoreboard players test CP1 CaptureTeam 1 1

Which would test for if CP1 was blue controlled, and similarly this:

/scoreboard players test CP1 CaptureTeam 0 0

To test if it was red controlled.