Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of my "Duties" API
var Duties = require('./index.js');
var main = new Duties();
var bot = new Bot(); // stub for other bot related code
var MiningTask = function* MiningTask(d, config) {
while(true) {
var block = bot.findBlockToBreak();
d.add(NavigateTask, block.location);
d.add(BreakBlockTask, block);
yield {};
}
};
var NavigateTask = function* NavigateTask(d, location) {
bot.navigate(location, d.resume);
yield d.suspend();
};
var BreakBlockTask = function* BreakBlockTask(d, block) {
bot.breakBlock(block, d.resume);
yield d.suspend();
};
var ExecuteTask = function* ExecuteTask(d, target) {
while(!target.dead) {
bot.attack(target, d.resume)
yield d.suspend();
}
};
main.add(MiningTask, {});
bot.on('threatDetected', function(threat) {
main.add(ExecuteTask, threat);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.