- `Texture` and `Color` can be picked as a variable kind, a struct field kind and a declared port kind; a new `Texture` node hands a picture id into the graph. Declared, a texture is its bare id – the `$texture` tag stays a list-only thing. - The `String` node is labelled "Text" like its kind; the type id stays. - Whole-number inputs (`Item at`, `Set item`, `Sub list`, `Fill`, `Repeat`, `Substring`, `To text`) show no decimals (`int()` in shared.ts). - All server projects are reseeded, so `legacyNodes.ts`, `migrateDeclaredLists` and the `ownerId` fallback go, with their tests. - Note `reseed-because-of-list` moved to done/; new note `refactor-types`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
22 lines
776 B
TypeScript
22 lines
776 B
TypeScript
import type { NodeDef } from '../../NodeRegistry';
|
|
import { asNumber, asString } from '../../values';
|
|
import { int, str } from '../shared';
|
|
|
|
export const Substring: NodeDef = {
|
|
type: 'Substring',
|
|
label: 'Substring',
|
|
category: 'data',
|
|
description:
|
|
'A part of a text: "count" characters starting at "start" (the first is 0). ' +
|
|
'A negative count reaches to the end.',
|
|
inputs: [str('text'), int('start'), int('count', -1)],
|
|
outputs: [str('text')],
|
|
params: [],
|
|
run: (_ctx, inputs) => {
|
|
const text = asString(inputs.text);
|
|
const start = Math.max(0, Math.floor(asNumber(inputs.start)));
|
|
const count = Math.floor(asNumber(inputs.count));
|
|
return { outputs: { text: count < 0 ? text.slice(start) : text.slice(start, start + count) } };
|
|
},
|
|
};
|