Saving and loading

This commit is contained in:
2021-11-05 20:02:20 +01:00
parent 0f8f5522fa
commit 897c912d67
8 changed files with 130 additions and 2 deletions

View File

@@ -0,0 +1,4 @@
export default function LoadCommand(args, context) {
context.print(`Loading game...`);
context.load();
}

View File

@@ -0,0 +1,4 @@
export default function SaveCommand(args, context) {
context.print(`Saving game...`);
context.save();
}

View File

@@ -0,0 +1,19 @@
export default function VolumeCommand(args, context) {
if (args.length < 3) {
return context.print(`Usage: volume <music/sfx/ambience> <0-100>`);
}
const value = parseInt(args[2]);
if (value > 100 || value < 1) {
return context.print(`No higher than 100 and no less than 1.`);
}
if (args[1] == "sfx") {
context.output.sound.setSFXVolume(value/100);
} else if (args[1] == "music") {
context.output.sound.setMusicVolume(value/100);
} else if (args[1] == "ambience") {
context.output.sound.setAmbienceVolume(value/100);
} else {
return context.print(`Invalid channel. Either ambience, sfx or music is allowed.`);
}
context.print(`${args[1]} volume set to ${value}%`)
}