16 lines
No EOL
589 B
JavaScript
16 lines
No EOL
589 B
JavaScript
// states/Observe.js
|
|
const { getBot } = require('../core/context');
|
|
const { chatWithAI } = require('../lib/ai-helper');
|
|
const config = require('../config.json');
|
|
|
|
module.exports = async function Observe() {
|
|
const bot = getBot();
|
|
console.log('[STATE] Observe');
|
|
|
|
// Example: count nearby entities. I will need to add way more to this observe file later.
|
|
const entities = Object.values(bot.entities).filter(e => e.type === 'mob');
|
|
const msg = `I see ${entities.length} mobs nearby. What should I do?`;
|
|
const response = await chatWithAI(msg, config.ai);
|
|
|
|
bot.chat(response);
|
|
}; |