ReferenceVerse

Conditional Button

conditional button

Updated
Watch the Knot — conditional-button in ~90 seconds.

One press and the mangrove gate grinds open, but only if the player holds the hidden pearl.

The conditional button device checks the player's inventory for a specific key item before firing, letting you gate progress behind exploration.

We set the required item count and interaction time in OnBegin, then subscribe to the NotEnoughItemsEvent to handle failed attempts.

Reach for the conditional button device whenever you want to lock a door, bridge, or reward behind a specific inventory item.

mangrove_gate := class(creative_device):
    @editable
    GateButton : conditional_button_device = conditional_button_device{}
    OnMissingItem(Agent : agent) : void =
        Print("You need a Mangrove Pearl!")
    OnBegin<override>()<suspends>:void =
        GateButton.SetItemCountRequired(0, 1)
        GateButton.SetInteractionTime(2.0)
        GateButton.NotEnoughItemsEvent.Subscribe(OnMissingItem)

Build your own lesson with conditional-button

Generate a personalized, compile-checked lesson grounded in this exact reference.

Build a lesson →