Day night cycle

This commit is contained in:
2026-09-26 11:03:07 -03:00
parent 8f32a59bd6
commit 8b549162c4
16 changed files with 244 additions and 6 deletions
+12 -1
View File
@@ -310,7 +310,9 @@ export class ModRuntime {
if (!/^[a-z0-9_]+$/.test(name)) {
throw new ModLoadError(mod, `command name "${name}" must be a-z, 0-9 and _`);
}
if (["give", "tps"].includes(name)) throw new ModLoadError(mod, `/${name} belongs to the engine`);
if (["give", "tps", "time"].includes(name)) {
throw new ModLoadError(mod, `/${name} belongs to the engine`);
}
const existing = this.commands.get(name);
if (existing) {
throw new ModLoadError(mod, `/${name} is also registered by ${existing.mod}`);
@@ -363,6 +365,15 @@ export class ModRuntime {
get seed() {
return game().world.seed;
},
get time() {
return game().world.time;
},
set_time: (time) => {
if (!Number.isInteger(time) || time < 0) {
throw new Error(`time must be a whole number of ticks, not ${time}`);
}
game().set_time(time);
},
},
players: {
all: () => game().players().map((p) => this.player(p)),