arx-level-generator
Version:
A tool for creating Arx Fatalis maps
53 lines • 1.79 kB
JavaScript
import { Audio } from '../../Audio.js';
import { Entity } from '../../Entity.js';
import { LoadAnim } from '../../scripting/commands/LoadAnim.js';
import { Interactivity } from '../../scripting/properties/Interactivity.js';
import { Scale } from '../../scripting/properties/Scale.js';
import { Speed } from '../../scripting/properties/Speed.js';
import { Variable } from '../../scripting/properties/Variable.js';
export class Lever extends Entity {
propIsPulled;
constructor({ isSilent = false, ...props } = {}) {
super({
src: 'fix_inter/lever',
...props,
});
this.withScript();
if (isSilent) {
Audio.mute(Audio.lever);
}
this.propIsPulled = new Variable('bool', 'pulled', false);
this.script?.properties.push(new Scale(0.7), this.propIsPulled, new Speed(3));
this.script?.on('init', new LoadAnim('action1', 'lever_up'));
this.script?.on('init', new LoadAnim('action2', 'lever_down'));
this.script?.on('init', () => {
return `
if (${this.propIsPulled.name} == 1) {
playanim action2
}
`;
});
this.script?.on('action', () => {
return `
${Interactivity.off}
TIMERenable -m 1 500 ${Interactivity.on}
if (${this.propIsPulled.name} == 1) {
set ${this.propIsPulled.name} 0
sendevent custom self off
playanim action1
} else {
set ${this.propIsPulled.name} 1
sendevent custom self on
playanim action2
}
`;
});
}
get isPulled() {
return this.propIsPulled.value;
}
set isPulled(value) {
this.propIsPulled.value = value;
}
}
//# sourceMappingURL=Lever.js.map