31 lines
671 B
TypeScript
31 lines
671 B
TypeScript
export type VNSceneMessage = {
|
|
type: "message";
|
|
text: string;
|
|
sfx?: string;
|
|
};
|
|
|
|
export type VNSceneCallback = {
|
|
type: "callback";
|
|
callback: () => void;
|
|
};
|
|
|
|
export type VNSceneBasisPart = string | VNSceneMessage | VNSceneCallback;
|
|
export type VNSceneBasis = VNSceneBasisPart[];
|
|
export type VNScenePart = VNSceneMessage | VNSceneCallback;
|
|
export type VNScene = VNScenePart[];
|
|
|
|
export function compile(basis: VNSceneBasis): VNScene {
|
|
let out: VNScene = [];
|
|
for (let item of basis.values()) {
|
|
if (typeof item == "string") {
|
|
out.push({
|
|
type: "message",
|
|
text: item,
|
|
});
|
|
} else {
|
|
out.push(item);
|
|
}
|
|
}
|
|
return out;
|
|
}
|