Denizen Script Commands


Commands are always written with a '-' before them, and are the core component of any script, the primary way to cause things to happen.
Learn about how commands work in The Beginner's Guide.


Showing 1 out of 183 commands...
NameSwitch
Syntaxswitch [<location>|...] (state:{toggle}/on/off) (duration:<value>) (no_physics)
Short DescriptionSwitches state of the block.
Full DescriptionChanges the state of a block at the given location, or list of blocks at the given locations.

Optionally specify "state:on" to turn a block on (or open it, or whatever as applicable) or "state:off" to turn it off (or close it, etc).
By default, will toggle the state (on to off, or off to on).

Optionally specify the "duration" argument to set a length of time after which the block will return to the original state.

Works on any interactable blocks, including:
- the standard toggling levers, doors, gates...
- Single-use interactables like buttons, note blocks, dispensers, droppers, ...
- Redstone interactables like repeaters, ...
- Special interactables like tripwires, ...
- Bells as a special case will ring when you use 'switch' on them, ...
- Almost any other block with an interaction handler.

This will generally (but not always) function equivalently to a user right-clicking the block
(so it will open and close doors, flip levers on and off, press and depress buttons, ...).

Optionally specify 'no_physics' to not apply a physics update after switching.
Related Tags<LocationTag.switched> Returns whether the block at the location is considered to be switched on. (...)
<MaterialTag.switched> Returns whether a material is 'switched on', which has different semantic meaning depending on the material type. (...)
Usage Example
#At the player's location, switch the state of the block to on, no matter what state it was in before.
- switch <player.location> state:on
Usage Example
#Opens a door that the player is looking at.
- switch <player.cursor_on> state:on
Usage Example
#Toggle a block at the player's foot location.
- switch <player.location>
Synonyms (Search Aid)toggle, lever, activate, power, redstone
Groupworld
Sourcehttps://github.com/DenizenScript/Denizen/blob/dev/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/SwitchCommand.java#L37