summaryrefslogtreecommitdiff
path: root/src/engine/entities/LambdaFactory.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/entities/LambdaFactory.ts')
-rw-r--r--src/engine/entities/LambdaFactory.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/engine/entities/LambdaFactory.ts b/src/engine/entities/LambdaFactory.ts
index 9ad1398..770c096 100644
--- a/src/engine/entities/LambdaFactory.ts
+++ b/src/engine/entities/LambdaFactory.ts
@@ -143,12 +143,19 @@ export class LambdaFactory extends Entity {
}
private spawnNewLambda(direction: Direction) {
+ try {
+ parse(this.code);
+ } catch (e: any) {
+ SOUNDS.get(Failure.name)!.play();
+ return;
+ }
+
const spawner = this.getComponent<GridSpawn>(ComponentNames.GridSpawn);
spawner.spawnEntity(direction);
- const text = this.getComponent<Text>(ComponentNames.Text);
- text.text = spawner.spawnsLeft.toString();
- this.addComponent(text);
+ const textComponent = this.getComponent<Text>(ComponentNames.Text);
+ textComponent.text = spawner.spawnsLeft.toString();
+ this.addComponent(textComponent);
SOUNDS.get(LambdaTransformSound.name)!.play();
}