yukinovel
Version:
Yukinovel is a simple web visual novel engine.
52 lines (51 loc) • 1.82 kB
TypeScript
export interface Variable {
name: string;
value: any;
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
persistent?: boolean;
}
export interface Condition {
variable: string;
operator: '==' | '!=' | '>' | '<' | '>=' | '<=' | 'contains' | 'in';
value: any;
logic?: 'and' | 'or';
}
export interface ScriptCommand {
type: 'set' | 'if' | 'jump' | 'call' | 'return' | 'wait' | 'custom';
params?: any;
conditions?: Condition[];
onTrue?: ScriptCommand[];
onFalse?: ScriptCommand[];
}
export declare class ScriptingEngine {
private variables;
private functions;
private stack;
private game;
constructor(game: any);
private initializeBuiltinFunctions;
setVariable(name: string, value: any, persistent?: boolean): void;
getVariable(name: string): any;
hasVariable(name: string): boolean;
deleteVariable(name: string): boolean;
getAllVariables(): Variable[];
getPersistentVariables(): Variable[];
loadPersistentVariables(variables: Variable[]): void;
evaluateExpression(expression: string): any;
private safeEval;
checkConditions(conditions: Condition[]): boolean;
private evaluateCondition;
executeScript(commands: ScriptCommand[]): Promise<void>;
private executeCommand;
registerFunction(name: string, func: Function): void;
unregisterFunction(name: string): boolean;
private getValueType;
processText(text: string): string;
increment(variableName: string, amount?: number): void;
decrement(variableName: string, amount?: number): void;
pushToArray(variableName: string, value: any): void;
popFromArray(variableName: string): any;
concatenateStrings(variableName: string, value: string): void;
clearTemporaryVariables(): void;
exportState(): any;
}