Region Facts and Variables
On static pages, you can read region state through facts:
Region Inside Factis1when the player is inside the region and0otherwise. Like the events, it uses the body based check: any part of the player overlapping the region counts.Region Player Count Factis the number of online players currently inside the region.Region Boundary Distance Factis the player's signed distance from the boundary in centimeters: negative inside, positive outside. The unit is centimeters because facts store whole numbers.Region Boundary Distance Variableis the same distance as a full precisionDoublein blocks, forVar<Double>fields.
One example per entry:
- Put the criteria
in_market == 1from aRegion Inside Facton aGive Item Action, so a merchant only hands over goods while the player stands in the market. - Show a sidebar line
Fighters: %typewriter_players_in_arena%from aRegion Player Count Fact, or gate a boss spawn onplayers_in_arena >= 2. - Damage players outside the safe zone with the criteria
safe_zone_distance > 0on aRegion Boundary Distance Fact, or only when they stray far withsafe_zone_distance > 500, which is 5 blocks out. - Bind a sound's volume variable to a
Region Boundary Distance Variable, so a warning hum gets louder the closer the player walks to the boundary.
Distance and the floor
The boundary of a region includes its floor and ceiling. When a region's bottom face lies on the ground, a
player walking inside is never more than about one block away from that face, so the distance fact reads
around -100 everywhere inside, no matter how close the walls are. This is correct, just rarely what you
want.
For that case, both distance entries and the proximity band entries have a Distance Mode field. The default
FULL measures against the whole boundary. HORIZONTAL measures horizontally only: it ignores floor and
ceiling and measures against the walls, as if the region extended infinitely up and down. A grounded arena
with HORIZONTAL reports how far the player is from the edge, which is usually the number you wanted.
Shared facts with a region group
Facts in Typewriter belong to a group, and by default every player is their own group. A
Region Members Group groups players by the region they are currently inside: everyone in the same region
reads and writes the same fact value, and a player in none of the configured regions has no group, so the
fact does nothing for them.
- On a static page, add a
Region Members Groupand select your region definitions inDefinitions. - On the fact you want shared, set its
Groupfield to the region group. It has to be a fact something writes to, like a counter or a phase number. The region's own facts read the world for whoever asks and have no stored value to share, so a group changes nothing on them.
Now a "levers pulled" fact counts pulls from the whole party standing in the puzzle room, and a boss phase fact set by one player's trigger is seen by everyone in the arena. A player inside several of the configured regions belongs to the first one in the list.
Example: a door that needs three players
We will make a sealed door react when three players stand on the pressure platform in front of it.
- On a manifest page, create a
Cuboid Region Definitionnamedboss_platformcovering the platform. - On a static page, add a
Region Player Count Factnamedplayers_on_platformwith itsRegionreference set toboss_platform.
- On a sequence page, add a
Region Enter Eventonboss_platform, so the check runs exactly when another player steps on. - Link it to the entry that plays your door opening payoff, with the criteria
players_on_platform >= 3on that entry. In this example a dialogue announces the rumbling door; in a real story this is where you trigger the cinematic, sound, or command that actually opens it.
The three pages together look like this:
- Region Definitions
- Region Facts
- Boss Door
This is an interactive graph of all the entries in the selected pages.
You can view different pages by clicking on the tabs. Each page contains a view of the entries in that page.
Click on an entry to view its details.
The count is evaluated when the criteria is checked. The first two players step on and nothing happens; when the third enters, the criteria passes and the door sequence fires.
When is the state updated?
Region facts are computed at the moment they are read; nothing is stored when a player crosses a boundary.
The triggered entries of an enter or leave event run right after the movement is applied, so by the time your
sequence reads a Region Inside Fact or a Region Player Count Fact, the value already reflects the
crossing that fired the event. In the door example above, the third player's enter event sees a count of 3,
themselves included.