Skip to content

Commit

Permalink
Alias change and code chnages
Browse files Browse the repository at this point in the history
  • Loading branch information
YetNT committed Apr 21, 2024
1 parent 3844b6b commit 03b9a1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions BP/scripts/funcs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Player, system, world, ChatSendBeforeEvent } from "@minecraft/server"

let ints: {
[key: string]: number
[key: string]: {
num: number,
exec: string
}
} = {}
let timeout = 20
let run: number;
Expand Down Expand Up @@ -75,7 +78,7 @@ function doevery(p: Player, msg: string) {

// Rest of doevery code, finally.

ints[name] = system.runInterval(() => {
ints[name].num = system.runInterval(() => {
let count: number = 0;
try {
p.runCommand(executable)
Expand All @@ -87,6 +90,7 @@ function doevery(p: Player, msg: string) {
}
}
}, secondsToTicks(time))
ints[name].exec = executable

r.c();

Expand All @@ -96,15 +100,15 @@ function doevery(p: Player, msg: string) {
}

function stopevery(p: Player, msg: string) {
const [, name] = msg;
const [, name] = msg.split(" ");
if (!(name in ints)) error(p, `Task with the name (${name}) does not exist.`);

delete ints[name];
p.sendMessage("Task has successfully been cleared!")
}

function listevery(p: Player) {
const intervalList = Object.keys(ints).map(name => `§lTask Name: §r§o${name}`);
const intervalList = Object.keys(ints).map(name => `§lTask Name: §r§o${name} | §lExecutable: §r§o${ints[name].exec}`);

if (intervalList.length == 0) {
p.sendMessage("No intervals have been set. yet.")
Expand Down
2 changes: 1 addition & 1 deletion BP/scripts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ world.afterEvents.chatSend.subscribe((arg) => {
case "de":
case "doevery":
case "startevery":
case "se":
case "sev":
doevery(p, message.substring(1));
break;
case "stopevery":
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

Execute a task (command) every `x` amount of seconds

_Aliases: `de`, `startevery`, `se`_
_Aliases: `de`, `startevery`, `sev`_

Usage:

Expand Down

0 comments on commit 03b9a1c

Please sign in to comment.