owobot/plugins/sc.js
7cc5c4f330d47060 de78065438 Initial commit
2024-07-06 11:02:11 -04:00

34 lines
1,001 B
JavaScript
Executable file

class SCTask{
constructor (failTask,chatCommand){
/*
* failed: Whether to run this task
* failTask: Command to run when failed is true
* chatCommand: Whether to run failTask in chat rather than in command block
*/
this.failed=false;
this.failTask=failTask;
this.chatCommand=chatCommand;
}
}
module.exports={
load:()=>{
},
loadBot:(b)=>{
b.sc_tasks={};
b.interval.sc=setInterval(()=>{
for(const i in b.sc_tasks){
if(b.sc_tasks[i].failed){
if(b.sc_tasks[i].chatCommand){
b.chat(b.sc_tasks[i].failTask)
} else {
b.ccq.push(b.sc_tasks[i].failTask) //Does not automatically reset
}
}
}
},1000)
b.add_sc_task=(name,failTask,chatCommand)=>{
b.sc_tasks[name] = new SCTask(failTask,chatCommand);
}
}
}