Automation without Writing Code

30 June 2020

This month we introduce the first automation feature: the ability to add custom behaviors to objects by just “recording” them.

Every object has a set of built-in behaviors. For example, a deck can be shuffled, a card can be flipped etc. However, you often want objects to behave in certain ways that are specific to your game.

Behaviors

behavior editor

The new Behavior Editor allows you to compose existing behaviors into more complex ones, including the ability to trigger them based on certain conditions.

To create a new behavior, just hit the record button and perform the actions that you want. The Behavior Editor will record these actions and turn them into a new behavior that you can refine further.

For example, if you want to create a “Draw” behavior that moves a card from the deck to a discard pile (while also flipping it), just perform those actions and the Behavior Editor will record them.

Our shiny new behavior can now be recalled just like a built-in behavior of the deck.

References

The behavior we created above is rather simplistic. It moves a specific card from the deck to the discard pile. You’ll notice that the objects in the behavior are all referred to by their ID’s.

screenshot

What you most likely want is to move the top card of the deck (whatever it happens to be) to the discard pile instead.

This is easily accomplished by clicking on the ID of the card in the MOVE step and changing it to a reference of the top child of “self” from the drop down. “self” is a convenient way to refer to the object that the behavior is attached to without needing to reference it with an ID. In our case, we created the behavior on the deck object, so our reference now points to the top card of the deck.

screenshot

Conditions

Behaviors that consist of a series of simple actions are convenient as shortcuts, but the real power comes when you use them conditionally.

For example, you might want to create an action that moves a card from the deck to your hand, but if the deck is already empty, then shuffle in the discard pile first.

Such actions can be created by clicking on the “Condition” button to add a condition. Clicking on the green bar of the condition will open a dropdown from where you can access different conditions, including that of a deck being empty.

Individual actions that you record can be moved into the body of the condition by dragging them there.

screenshot

Don’t worry if this looks a bit cryptic. You’ll get used to it in no time. There are also several features planned to make behaviors easier to read (showing previews of the objects rather than opaque ID’s for example).

Also note that you don’t have to directly interact with the Behavior Editor if all you’re doing is just recording a few actions to create a shortcut.

What’s Coming Next

Turn Management is high on the priority list. This will include the ability to trigger behaviors automatically at the start of a player’s turn. This will allow having cards be automatically dealt to players at the start of a round (for example).

Join our Discord server or subscribe to the mailing list to find out how you can try a preview of Boardgame Lab today!