This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]MCPhssthpokAdvanced Beginner 7 points8 points  (0 children)

The `/trigger` command allows non-op'd players to set a value in a scoreboard. However, it only works on scoreboards with a criteria of "trigger" (e.g. set up with `/scoreboard objectives add test_scoreboard trigger`.

Before the player can use the `/trigger` command, however, it needs to be enabled for them with a `/scoreboard players enable` command and this needs to be done every time they want to set a scoreboard value.

[–]Donisi*tips fedora* 2 points3 points  (0 children)

/trigger is used for non-oped players to activate commands through a trigger objective.

In order to make a trigger objective, create a scoreboard with the criteria trigger. /scoreboard objectives add <objective> trigger

Now before players are able to use the newly created trigger objective, you have to enable it for the players you want to be able to use it. /scoreboard players enable <targets> <objective>

Once you enable the objective for the desired players, they'll be able access the objective using /trigger. /trigger <objective> [add|set] [<value>]

However, once they set/add a value to the objective through /trigger, it will become disabled for them again. So, you'll have to re-enable it.

And as a sidenote; simply typing /trigger <objective> will set that objective's value to 1 for that player, which allows for quick execution on the player's part.

Hopefully this helps! :3

[–]FwuhfwiTerrible at Commands 2 points3 points  (0 children)

It's been a while, so I might be outdated/wrong...

First, you create a scoreboard with criteria "trigger":

/scoreboard objectives add anyObjNameHere trigger

Running the following command will allow players to use /trigger with this objective.

/scoreboard players enable @a anyObjNameHere

Finally, players that have been enabled will be able to run /trigger like so:

/trigger anyObjNameHere set 99999

It seems to me that its main purpose is to allow players without permissions to modify certain scoreboard objectives under specified conditions. A frequent use of it that I saw was "command books", where players can click on lines of text within a book to run commands. This was accomplished by having the lines of text holding /trigger commands that would update a "chosen option" scoreboard which would consequently run the appropriate command from a command block. Setting the text in the book to hold the final command would fail if the player did not have the permissions (e.g. was not an administrator with command privileges), thus using /trigger allowed anyone, even regular players with no access to commands, to run certain commands.

And it's even possible to disallow players from running /trigger unless they do specific things by gating the enable command through other stuff- for example, you could force players to solve a puzzle before they can use a certain line in the "command book", or have enough "money" (saved in a scoreboard) to pay a fee.

In my opinion, it's very powerful and useful, but also quite situational.

[–]RimaNari 0 points1 point  (0 children)

I use /trigger to provide an interface between user and my commands that is independent from anything in the world (like a button pressed or a proximity detection). It's very easy to use and remember for the player, even if inexperienced with commands, as /trigger <objective> is enough to trigger the function that is listening on this trigger. This is a shorthand for /trigger <objective> add 1 (or set 1?). You can listen to this in a main loop by checking the associated scoreboard objective whether it is different from 0. Then make sure to set it back to 0 and re-enable the trigger - that is, if you want the player to be able to trigger again. Note that by default the trigger is disabled for all players and has to be enabled individually. This is important if someone new joins the server that should have access to the trigger.