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

axolemma

v0.5.3

Published

A tool to procedurally generate areas compatible with the Ranvier MUD engine.

Downloads

4

Readme

Axolemma

A tool for procedurally generating Ranvier areas.

--

How to Install

npm install --save axolemma

How to Use

Axolemma is usable as a CLI tool and can also be used as a library.

To use it as a CLI tool, navigate to the working directory where you would like Axolemma to generate the map files, and type axolemma.

Axolemma will ask a series of questions and, as a result, generate an area for you.

screenshot

Here is a recipe for using Axolemma programmatically:

// Require-able like any other library.
const Axolemma = require('axolemma')

const {manifest, graphic, rooms, yaml} = Axolemma.generate({ // Programmatically pass in options
  type: 'Digger' // Uses ROT-js well-documented map generation algorithms.
  writeToFile: true // Can write YAML definitions to file for static persistence
})

// Returns an old-school ASCII map of your area.
console.log(graphic)

// Returns YAML string.
console.log(yaml)

// Returns area manifest as JS object.
console.log(manifest)

// Returns Ranvier-compatible room definitions.
const newRooms = rooms.map(
  roomDef => new Room(roomDef)
);

Configuration

When using Axolemma programmatically, you can customize the default options using either a .axolemmaconfig file or by adding an "axolemma" field in your package.json.

Your .axolemmaconfig can be either a JavaScript module or a JSON file. Axolemma will crawl up the directory tree to find the file so it can be in the root directory of your Ranvier bundle, the root of your fork of Ranvier, or even in your user home directory. It will use the 'nearest' config it finds, so you can have multiple configurations at different nesting levels.

Configuration precedence goes as follows:

  • Options passed in programmatically
  • .axolemmaconfig options
  • Options from "axolemma" field in package.json
  • Axolemma's built-in defaults.

Axolemma accepts the following options:

/**
  * @typedef {Object} AxolemmaOptions
  * @property {number} [width] The maximum width of the area you'd like to generate (x coordinates). Defaults to 20.
  * @property {number} [height] The maximum height of the area you'd like to generate (y coordinates). Defaults to 20.
  * @property {number} [depth] Unimplemented. The maximum depth (z coordinates or floors) of the area you'd like to generate. Defaults to 0 (2D area).
  * @property {boolean} [writeToFile] Whether to write the YAML result to file or simply return the data. Defaults to false.
  * @property {string} [filepath] Path to write YAML to. Defaults to current working directory
  * @property {string} [areaTitle] Title of area to generate. Defaults to 'Generated Area'
  * @property {Object} [areaInfo] Info object for area manifest. Defaults to object with respawnInterval property set to 60.
  * @property {string} [genericRoomTitle] A title to be used for all of the rooms in your generated area. Defaults to 'An Empty Room'.
  * @property {string} [genericRoomDesc] A description to be used for all of the rooms in your generated area. Defaults to 'There is nothing particularly interesting about this place.'
  * @property {string} [type] The 'type' of map creator to use. This must be the name of a ROT-js Map constructor. Defaults to 'Uniform'.
  * @property {timeLimit} [number] Amount of ms to wait for the ROT-js map generator algorithms to complete before giving up. Defaults to 60,000 (one minute).
  */

Also, check out the ROT-js documentation for the mapper 'type' that you are using, for additional options.

Room Templates & Weighted Tables

As of version 0.5.0, it is possible to use Axolemma to procedurally generate an area with multiple kinds of rooms. See examples/template-areas/json for the full example, but it works like this:

// .axolemmaconfig.js
module.exports = {
  type: 'Digger',
  areaTitle: 'Abandoned Mines',

  // ... more options
  // You could probably inline this but I like to keep 'em separated.
  weightedRoomsTable: require('./rooms-table')
}

// rooms-table.js

// These numbers are arbitrary.
// Lower = more rare, higher = more common.
// You could use any scale you want, these numbers could be
// 10, 50, 100. Feel free to get more granular.
const COMMON = 5
const UNCOMMON = 3
const RARE = 1

module.exports = {
  mineshaft: {
    weight: UNCOMMON,
    title: 'Abandoned Mineshaft',
    description: 'A dark pit looms below you, boarded over by loose planks. The walls around you bear the marks of generations worth of pickaxes.'
  },

  minefloor: {
    weight: COMMON,
    // ...
  },

  oredeposit: {
    weight: RARE,
    // ...
  }
};

Based on this example, Axolemma will output an area with rooms featuring the properties specified in room-table.js. While it is pseudo-random, approximately 1 out of every 9 rooms will be an ore deposit, 3 out of 9 will be mineshafts, and 5 out of 9 will be a boring floor with rocks on it.

Future goals for this include adding arbitrary properties to the room templates, so that one could specify which NPCs are in a room, which scripts, and more.

Misc.

Axolemma is currently in an early alpha stage. Use at your own risk.

The areas it generates are fairly generic in this iteration so much hand-editing is still required.

If you're using this in your Ranvier server to dynamically generate large amounts content on the fly, consider using a Cluster or similar to avoid blocking the main process with Axolemma.

In testing on a machine with 8GB RAM, Axolemma can generate a 20x20 area in a matter of milliseconds.

See the examples directory for code snippets that can be used to make Axolemma play nice with Ranvier, and additional how-tos.