npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

creep-tasks

v1.3.0

Published

Tasks for your creeps

Downloads

16

Readme

creep-tasks npm version Build Status

creep-tasks is a plugin for your Screeps codebase which adds a concise and flexible creep.task property to your creeps. Tasks are persistent objects that generalize the concept of "do action X to thing Y until condition Z is met" and they can save a lot of convoluted and redundant code in creep logic. A Task object contains the necessary logic for traveling to a target, performing an action on the target, and realizing when a task is no longer sensible to continue.

creep-tasks has been adapted from the Overmind Screeps AI.

Documentation

For an overview of how Tasks work and a full API reference, please refer to the creep-tasks Wiki.

Examples

Many Screeps bots use decision trees which run every tick to determine what a creep should be doing. Tasks streamline this process into two separate parts: task assignment and task execution. Since tasks are persistent, you only need to run decision tree logic when a creep is idle. Here's a very simple example of writing an upgrader role using tasks:

/* main.js */

let Tasks = require('creep-tasks');

// Upgraders will harvest to get energy, then upgrade the room controller
let roleUpgrader = {
    newTask: function(creep) { // task assignment logic
        if (creep.carry.energy > 0) {
            creep.task = Tasks.upgrade(creep.room.controller);
        } else {
            creep.task = Tasks.harvest(creep.room.find(FIND_SOURCES)[0])
        }
    }
};

module.exports.loop = function () {
    /* (Spawning logic would go here) */
    let upgraders = _.values(Game.creeps);
    for (let upgrader of upgraders) {
        if (upgrader.isIdle) { // obtain a new task if the creep is idle
            roleUpgrader.newTask(upgrader);
        }
        upgrader.run(); // run the assigned task
    }
};

This repository contains simple example bots built using creep-tasks written in JavaScript and in TypeScript. You can see more complex creep-tasks examples in the Overmind codebase.

Installation

There are several ways to install creep-tasks. I would recommend using npm, but depending on how your environment is set up and how much you'd like to modify the source, installing from binary or from source might work better for you.

(JavaScript/TypeScript) Install from npm:

Navigate to your project root and run npm install creep-tasks. The npm module comes with included typings if you are using TypeScript. Use var Tasks = require('creep-tasks') to import the Tasks module in JS or import Tasks from 'creep-tasks' to import in TS.

(JavaScript only) Install from compiled module:

  1. Download or copy/paste the code in bin/creep-tasks.js and put it in a new module.
  2. Add require('creep-tasks') to your main.js file outside of the main loop.
  3. Use var Tasks = require('creep-tasks') wherever you need to set creep tasks.

(TypeScript only) Install from source:

  1. Download this repository and copy the src/creep-tasks directory to somewhere in your codebase.
  2. Import the necessary prototypes in main.ts with import 'creep-tasks/prototypes' outside of the main loop.
  3. Use import {Tasks} from 'creep-tasks/Tasks' (path to Tasks.ts) whenever you need to set creep tasks.

Contributing

If you find an issue with creep-tasks or want to leave feedback, please feel free to submit an issue. If you'd like to contribute to creep-tasks, pull requests are also welcome!

Changelog

2018.8.1:

  • Version 1.3 released - adds chaining functionality with Tasks.chain(), adds TaskWithdrawAll, adds nextPos option, and fixes bugs

2018.6.29:

  • Version 1.2 released - adds TaskTransferAll, adds oneShot option, and fixes bugs

2018.5.1:

  • Version 1.1 released - repackaged for better npm support and now with included typings

2018.4.29:

  • Initial release