You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vore-rpg/src/scripting/ScriptValue.ts

26 lines
634 B

export enum ScriptValueTypes {
NUMBER = "number"
}
export interface NumberValue {
readonly type: ScriptValueTypes.NUMBER,
readonly value: number,
}
export function numberValue(value: number|string) {
if (typeof value === "string") {
return {
type: ScriptValueTypes.NUMBER,
value: parseInt(value, 10),
}
} else {
return {
type: ScriptValueTypes.NUMBER,
value,
}
}
}
export function isNumberValue(value: ScriptValue): value is NumberValue {
return value.type === ScriptValueTypes.NUMBER
}
export type ScriptValue = NumberValue