State dependent modules

This page describes the setup to create state dependent modules. These modules can be used to dynamically show/hide staff items by activating other staff items. Example and use cases below.

custom module config

Each custom module can configure these 3 optional configuration parameters:

option
description

enabled-on-state

A string value which defines that this module should only get enabled when the given state is active

enable-state

Tell staff++ to enable this state when the module is executed.

disable-state

Tell staff++ to disable this state when the module is executed.

Modes config

In the modes config we can specify which states should be active when entering the mode:

modes:
  default:
    ...
    initial-item-states:
    - nightvision-off

Using this system we can create modules which are enabled only on certain states. Because state changes can be done by staff modules themselves we can create some flexible configurations.

Examples

Nightvision modules

We defined 2 modules. 1 for toggling night mode on. And one for turning it off. The first module switches the state to nightvision-on This state change makes it so that the second module will be enabled and shown inside the player's inventory. Vice versa the second module triggers the state to nightvision-off

Modes config

To configure the mode I did the following:

  • disable the default night vision of staff mode

  • Disable night vision when exiting staff mode

  • Set initial state to night vision off. So when you enter staff mode the obsidian block will be in your inventory

  • We defined the module on the same inventory location. Due to the state only one will be shown at a time.

Last updated

Was this helpful?