mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-09-10 12:02:59 +02:00
always load npc
This commit is contained in:
parent
1a148c0222
commit
825c369e8d
3 changed files with 2 additions and 4 deletions
|
@ -207,7 +207,6 @@ export const actionsList = [
|
|||
'quantity': '(number) The quantity of the goal to set. Default is 1.'
|
||||
},
|
||||
perform: async function (agent, name=null, quantity=1) {
|
||||
if (!agent.npc.data) return 'NPC module is not loaded.';
|
||||
await agent.npc.setGoal(name, quantity);
|
||||
return 'Set goal: ' + agent.npc.data.curr_goal.name;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,6 @@ export class NPCContoller {
|
|||
}
|
||||
|
||||
init() {
|
||||
if (this.data === null) return;
|
||||
|
||||
for (let file of readdirSync('src/agent/npc/construction')) {
|
||||
if (file.endsWith('.json')) {
|
||||
try {
|
||||
|
@ -68,6 +66,7 @@ export class NPCContoller {
|
|||
}
|
||||
|
||||
this.agent.bot.on('idle', async () => {
|
||||
if (this.data.goals.length === 0 && !this.data.curr_goal) return;
|
||||
// Wait a while for inputs before acting independently
|
||||
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||
if (!this.agent.isIdle()) return;
|
||||
|
|
|
@ -24,8 +24,8 @@ export class NPCData {
|
|||
}
|
||||
|
||||
static fromObject(obj) {
|
||||
if (!obj) return null;
|
||||
let npc = new NPCData();
|
||||
if (!obj) return npc;
|
||||
if (obj.goals) {
|
||||
npc.goals = [];
|
||||
for (let goal of obj.goals) {
|
||||
|
|
Loading…
Add table
Reference in a new issue