Skip to content
McHorse edited this page Jun 19, 2021 · 4 revisions

States is a mechanism that allows to store numerical and string values either globally, per player or an NPC. States can be used in expressions, scripts, and managed by /mp state commands.

It's a really powerful tool that you can use arbitrarily to drive story progression of your adventure map.

Server states are always denoted by ~, and individual player states can be accessed either through player target selectors like @r or using player's username/UUID.

Example

A basic example would be, let's say, you have a map where you have the main altar where the player should get, but in order to open the main gate to that altar they must to activate two levers in two separate places. To achieve that, you can place two levers which are connected to command blocks behind the wall:

  • First command block: /mp state set ~ a 1
  • Second command block: /mp state set ~ b 1

And for the gate you can use simple 2x2 door (something like this) which connect to an emitter block which has following expression:

!state("a", "~") || !state("b", "~")

This expression basically mean that it will emit signal if either global state a or global state b is 0. This makes the emitter block powered until the moment both a and b become 1.

Once both global states a and b become 1, then emitter will stop emitting the signal and will open the piston doors!

Clone this wiki locally