always load npc

This commit is contained in:
Kolby Nottingham 2024-05-02 22:32:16 -07:00
parent 1a148c0222
commit 825c369e8d
3 changed files with 2 additions and 4 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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) {