7. Create a new step in Blueprint#

For: Blueprint programmers. Needs: Tutorial 2. You will: add the sentence Then this number should be greater than N to BlueprintFeature using three Blueprints and no C++.

The pattern is the one every step follows: a tagged data class for the value, a step that does the work, and a step entry that connects a sentence to the step.

1. The tagged data: Data_Threshold#

  1. In your project’s Content folder, Add > Blueprint Class, search for and pick ZagalaSpec Tagged Data as parent. Name it Data_Threshold.

  2. Open it. In Class Settings > Interfaces, add ZagalaSpec Value Store. This lets the default converter hand the captured text to your class.

  3. Add an integer variable Threshold.

  4. Implement the interface event Store Value (right-click the graph, Event Store Value): String to Int (Value To Store) → Set Threshold.

  5. In Class Defaults set Data Tag to a new gameplay tag, for example MyGame.Data.Threshold (create it in Project Settings > Gameplay Tags or with the + in the tag picker).

  6. Compile and save.

BP_Data_GivenNumber in BlueprintFeature is built exactly like this; open it to compare.

2. The step: Step_NumberGreaterThan#

  1. Add > Blueprint Class, parent ZagalaSpec Default Execution Step. Name it Step_NumberGreaterThan.

  2. Open the event graph. Override Internal Execute (it has one input, Assigned Cacher). Build:

Event Internal Execute (Assigned Cacher)
  → Add Local Setup Data To Cache (Assigned Cacher)
  → Get Data (Assigned Cacher, BP_Data_GivenNumber)  → cast → Given
  → Get Data (Assigned Cacher, Data_Threshold)    → cast → Threshold
  → Branch: Given.Number > Threshold.Threshold
       true  → Broadcast Success
       false → Broadcast Failure (Reason = Format "given number {0} is not greater than {1}")

Get Data and the other cache nodes are under DSL in the node palette (they come from UZagalaSpecTaggedDataHandler); pass the Assigned Cacher object as the first input and the class as the second. 3. Add a guard: if either Get Data returns null, Broadcast Failure with a reason and stop. A step must broadcast exactly once on every path, including the ones you did not expect. 4. Compile and save.

This step does everything inline, like BP_Step_GivenANumber. If you wanted the layered form, you would make the parent ZagalaSpec Chain Link On Step (from the examples module), construct a DSL Blueprint into Action, subscribe and execute, as BP_Step_ThenNumberShouldBe does.

3. The step entry: StepEntry_NumberGreaterThan#

  1. Add > Blueprint Class, parent ZagalaSpec Regex Step Entry. Name it StepEntry_NumberGreaterThan.

  2. In Class Defaults:

    • Pattern: ^(?:Then |And )this number should be greater than (\d+)$

    • Step Class: Step_NumberGreaterThan

    • Comments (optional): what the sentence means, for whoever reads the registry later.

  3. Save. Saving registers the pattern. Check Window > Output Log: no LogZagalaSpec warning about a duplicate pattern should appear. If one does, another entry already owns that exact pattern and yours is ignored until you change it.

A regex step entry Blueprint

4. Use it#

  1. Open BlueprintFeature (or your own feature). In Check Data Retrieval press + on Expectations and type And this number should be greater than 5.

  2. Matched Step Entry shows StepEntry_NumberGreaterThan. Expand the capture group: Capture Group Value 5, Scope Local. Set Group Value Class to Data_Threshold.

  3. Press Check. Green. Change the sentence to greater than 6; red, with your reason. Restore it and save.

Tip

Setting the Group Value Class by hand on every use gets old. Two ways around it: add a Global Capture Group Classes row in Project Settings for words that always mean the same thing and have configurators switch the group’s Scope to Global; or, in C++, read the raw capture text in the step’s Setup so no class is needed at all (Tutorial 9 shows UZagalaSpecCEFocusItem doing exactly that).

Rules you just followed#

  1. The tagged data class implements ZagalaSpec Value Store so text becomes a value.

  2. The step calls Add Local Setup Data To Cache before reading, reads through Get Data, and broadcasts exactly once per path.

  3. The step entry’s pattern is unique, anchored with ^ and $, and keeps keywords in a non-capturing group so that only values are captured.

  4. If the step held state (a spawned actor, a timer), it would reset it in Internal Teardown.

Next: 8. Create a new step in C++ does the same in C++.