Answers from the documentation; checking which model is on duty
Hi - I answer from the OpenSmartRoute documentation: routing, the API, plans and quotas, self-hosting. Ask away, or open a support ticket if you need a person.
Grounded in the docs - follow a source before acting on it.
actions-and-utilities - Skill - OpenSmartRoute
Skillv1.0.0
actions-and-utilities
Use this skill when working with Phaser 4 utility functions, actions, alignment, grid layout, or batch operations on game objects.
Imported from phaserjs/phaser (skills/actions-and-utilities/SKILL.md) via skills.sh. Install upstream with npx skills add phaserjs/phaser --skill actions-and-utilities. Copyright stays with the author.
Phaser 4 -- Actions & Utility Functions
Phaser.Actions namespace for batch operations on Game Object arrays, plus Phaser.Utils.Array, Phaser.Utils.Objects, and Phaser.Utils.String helper functions.
Related skills: ../groups-and-containers/SKILL.md, ../sprites-and-images/SKILL.md
Quick Start
// Create 20 sprites and batch-position them in a gridconst sprites = [];for (let i = 0; i < 20; i++) { sprites.push(this.add.sprite(0, 0, 'gem'));}// Arrange into a 5x4 gridPhaser.Actions.GridAlign(sprites, { width: 5, height: 4, cellWidth: 64, cellHeight: 64, x: 100, y: 100});// Fade alpha from 0 to 1 across all spritesPhaser.Actions.Spread(sprites, 'alpha', 0, 1);// Offset each sprite's x by 10, with a step of 2 per itemPhaser.Actions.IncX(sprites, 10, 2);// Works with Groups tooconst group = this.add.group({ key: 'star', repeat: 11 });Phaser.Actions.PlaceOnCircle(group.getChildren(), new Phaser.Geom.Circle(400, 300, 200));
Core Concepts
The Actions Pattern
Every Action in Phaser.Actions follows the same pattern:
First argument is always an array of Game Objects (or any objects with the required public properties like x, y, alpha, etc.).
Returns the same array, enabling chaining or pass-through.
Works with Groups by passing group.getChildren().
Actions do NOT store state. They are one-shot batch operations.
PropertyValueSet and PropertyValueInc
Most Set/Inc actions delegate to two core functions:
PropertyValueSet(items, key, value, step, index, direction) -- Sets items[i][key] = value + (i * step).
PropertyValueInc(items, key, value, step, index, direction) -- Adds items[i][key] += value + (i * step).
The step parameter adds an incremental offset per item. The index and direction parameters control iteration start point and order (1 = forward, -1 = backward).
Geometry-Based Placement
Actions like PlaceOnCircle, PlaceOnLine, RandomRectangle, etc. accept Phaser geometry objects (Phaser.Geom.Circle, Phaser.Geom.Line, etc.), NOT Game Object shapes. If using a Phaser.GameObjects.Circle, pass its .geom property instead.
Guaranteed stable sort (merge sort fallback for engines without native stable sort)
Swap
(array, item1, item2)
Swap two items in-place
Also includes Phaser.Utils.Array.Matrix sub-namespace for 2D matrix operations.
Object Utilities
Namespace: Phaser.Utils.Objects
Function
Signature
Description
Clone
(obj)
Shallow clone of object
DeepCopy
(obj)
Recursive deep copy of object or array
Extend
(target, ...sources)
jQuery-style extend; copies properties from sources to target
GetAdvancedValue
(source, key, defaultValue)
Like GetValue but resolves random/callback config values
GetFastValue
(source, key, defaultValue?)
Top-level-only property lookup; no dot-path support. Faster than GetValue
GetMinMaxValue
(source, key, min, max, defaultValue)
Get value clamped between min and max
GetValue
(source, key, defaultValue, altSource?)
Dot-path property lookup (e.g. 'render.screen.width'). Falls back to altSource then defaultValue
HasAll
(source, keys)
True if source has ALL listed keys
HasAny
(source, keys)
True if source has ANY listed key
HasValue
(source, key)
True if source has the key
IsPlainObject
(obj)
True if obj is a plain {} object (not DOM, not window)
Merge
(obj1, obj2)
Merge obj2 into a clone of obj1
MergeRight
(obj1, obj2)
Merge obj1 into a clone of obj2
Pick
(source, keys)
Return new object with only the specified keys
SetValue
(source, key, value)
Set a dot-path property value
String Utilities
Namespace: Phaser.Utils.String
Function
Signature
Description
Format
(string, values)
Replace %1, %2, etc. markers with array values
Pad
(str, len?, pad?, dir?)
Pad string to length. dir: 1=left, 2=right, default=both
RemoveAt
(string, index)
Remove character at index
Reverse
(string)
Reverse the string
UppercaseFirst
(string)
Capitalize first character
UUID
()
Generate RFC4122 v4 UUID string
Common Patterns
Using Actions with Groups
const enemies = this.add.group({ key: 'enemy', repeat: 9 });// Position all children in a gridPhaser.Actions.GridAlign(enemies.getChildren(), { width: 5, height: 2, cellWidth: 80, cellHeight: 80, x: 100, y: 50});// Fan out alpha across all enemiesPhaser.Actions.Spread(enemies.getChildren(), 'alpha', 0.3, 1);
Step Parameter for Staggered Values
// Place sprites starting at x=100, each one 50px further rightPhaser.Actions.SetX(sprites, 100, 50);// Result: items[0].x=100, items[1].x=150, items[2].x=200, ...// Increment rotation with increasing stepPhaser.Actions.Rotate(sprites, 0.1, 0.05);// Result: items[0].rotation += 0.1, items[1].rotation += 0.15, items[2].rotation += 0.2, ...
Scatter Then Constrain
const bounds = new Phaser.Geom.Rectangle(0, 0, 800, 600);// Random scatterPhaser.Actions.RandomRectangle(sprites, bounds);// Keep wrapped in bounds during updatePhaser.Actions.WrapInRectangle(sprites, bounds);
GetValue for Config Parsing
// Deep property access with fallbackconst width = Phaser.Utils.Objects.GetValue(config, 'render.screen.width', 800);// Fast top-level lookup (no dot-path, better performance)const speed = Phaser.Utils.Objects.GetFastValue(config, 'speed', 100);
Install actions-and-utilities and it becomes one more candidate the router can pick - when it fits.
A listing is a routing target with a manifest: what it does, which domains it covers, what it costs and who publishes it. Once installed it sits beside your own models and tools, is scored like any other candidate for each request, and shows up in the trace when it wins. Ratings come from workspaces that installed it, one per account.
When a provider is down or over quota the request moves on; the trace says it did.
Use it
Copy one of these into your project. Installing also returns the manifest and these snippets.
# after Install: the listing is in your workspace's routing pool - a plan picks it for its slotcurl-s-X POST https://api.opensmartroute.ai/api/v1/route -H 'Authorization: Bearer $OSR_API_KEY' -H 'Content-Type: application/json' -d '{"text": "...", "plan": true}'
Manifest
An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.