UNPKG

arx-level-generator

Version:
58 lines 1.72 kB
import { ScriptProperty } from '../ScriptProperty.js'; /** * A ScriptProperty for declaring in-game variables for an Entity or globally * * @extends ScriptProperty * @see https://wiki.arx-libertatis.org/Script:Variables */ export class Variable extends ScriptProperty { propType; propName; startUninitialized; constructor(type, name, value, startUninitialized = false) { super(value); this.propType = type; this.propName = name; this.startUninitialized = startUninitialized; } toString() { if (this.startUninitialized) { return ''; } return `set ${this.name} ${this.scriptValue}`; } get name() { switch (this.propType) { case 'bool': case 'int': return `§${this.propName}`; case 'float': return `@${this.propName}`; case 'string': return `£${this.propName}`; case 'global bool': case 'global int': return `#${this.propName}`; case 'global float': return `&${this.propName}`; case 'global string': return `$${this.propName}`; } } get scriptValue() { switch (this.propType) { case 'bool': case 'global bool': return `${this.value ? 1 : 0}`; case 'int': case 'float': case 'global int': case 'global float': return `${this.value}`; case 'string': case 'global string': return `"${this.value}"`; } } } //# sourceMappingURL=Variable.js.map