Day night cycle
This commit is contained in:
@@ -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)),
|
||||
|
||||
Reference in New Issue
Block a user