Problem
The twee macro system supports dot-path assignment on object variables:
{set $alma.view = "home"}
{set $character.level = $character.level + 1}
But the JavaScript Story.set API does not — it treats the key as a flat string:
Story.set('alma.view', 'home'); // creates a variable literally named "alma.view"
// instead of setting $alma's "view" property
This is because Story.set passes the key directly to state.setVariable(name, value) without any dot-path splitting:
set(nameOrVars: string | Record<string, unknown>, value?: unknown): void {
const state = useStoryStore.getState();
if (typeof nameOrVars === 'string') {
if (nameOrVars.startsWith('%')) {
state.setTransient(nameOrVars.slice(1), value);
} else {
state.setVariable(nameOrVars, value);
}
}
// ...
}
Expected behavior
Story.set('alma.view', 'home') should behave the same as {set $alma.view = "home"} — setting the view property on the $alma object variable.
Similarly, Story.get('alma.view') should return the view property of $alma, consistent with how {$alma.view} works in twee.
Motivation
When game code uses an object variable (e.g. $alma = { view: "home", expanded: "", ... }) to group related UI state, the TS action layer currently has to do read-modify-write:
const alma = Story.get('alma');
Story.set('alma', { ...alma, view: 'home' });
This is verbose and error-prone compared to the twee equivalent. Dot-path support in the API would allow the natural:
Story.set('alma.view', 'home');
Problem
The twee macro system supports dot-path assignment on object variables:
But the JavaScript
Story.setAPI does not — it treats the key as a flat string:This is because
Story.setpasses the key directly tostate.setVariable(name, value)without any dot-path splitting:Expected behavior
Story.set('alma.view', 'home')should behave the same as{set $alma.view = "home"}— setting theviewproperty on the$almaobject variable.Similarly,
Story.get('alma.view')should return theviewproperty of$alma, consistent with how{$alma.view}works in twee.Motivation
When game code uses an object variable (e.g.
$alma = { view: "home", expanded: "", ... }) to group related UI state, the TS action layer currently has to do read-modify-write:This is verbose and error-prone compared to the twee equivalent. Dot-path support in the API would allow the natural: