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

@v0rt4c/otbm

v0.2.0

Published

This is a library that can read/write tibia .OTBM files.

Downloads

39

Readme

@v0rt4c/otbm

Information

This library can (parse/read) and write binary .OTBM open Tibia binary map files. It should support all .OTBM map files up to version 3 that have been created with the popular open Tibia map editor from Remere.

However, when it comes to some items (splash, fluid container and stackable). You need the corresponding .OTB file to be able to read and write them correctly. This is because the .OTBM file itself has no information of what kind of items it holds. Therefore some attributes might be missing for these items. More specifically for stackable items the count, for splash items what kind of splash it is (water, beer, manafluid) etc... I've tried to mitigate this problem for most cases by saving any unknown attribute value to an attribute property named subType.

During tests on a Macbook air with an M1 processor this library has proven to be relatively fast. It will parse a ~65MB .OTBM file and structure it up into a JavaScript object nodal tree in ~3.5 seconds. For reference a 65MB .OTBM map file is the equivalent of the whole Tibia world in version 7.4. Writing from the structured nodal tree back into .OTBM binary format again takes about half the time on the same computer, so for this example about 1.8 seconds.

Compatability

The library has been created with compatability in mind. Therefore all work with binary data is done with Uint8Arrays that exist natively on all JS platforms (NodeJS, Deno & Browser). It does not use or require any third party dependencies.

Use cases

With this library you can create tools for working/editing/creating .OTBM files. You could even create a modern map editor that runs in the browser.

How to use

NodeJS / Browserify

ES6

import { OTBMReader, OTBMWriter } from '@v0rt4c/otbm';

CommonJS

const { OTBMReader, OTBMWriter } = require('@v0rt4c/otbm');

Deno

import { OTBMReader, OTBMWriter } from 'https://deno.land/x/[email protected]/mod.ts';

All platforms

import the raw .OTBM buffer however you like, for example with fs.readFile in node, Deno.readFile for deno or with a file input for browsers. Convert the buffer to an Uint8Array then:

Reading

const reader = new OTBMReader(otbmFileBuffer);
const nodeTree = reader.getRootNode();

Writing

const writer = new OTBMWriter(nodeTree);
const otbmBuffer = writer.writeBuffer();

The tree

After parsing the .OTBM file you will receive a javascript object tree structure that looks like this:

<ref *1> RootNode {
  properties: {},
  parent: null,
  children: [
    MapData {
      properties: { description: [Array], spawnFile: "map-spawn.xml", houseFile: "map-house.xml" },
      parent: [Circular *1],
      children: [ [Object], [Object], [Object] ],
      prevSibling: null,
      nextSibling: null,
      type: 2
    }
  ],
  prevSibling: null,
  nextSibling: null,
  type: 0,
  version: 2,
  width: 2048,
  height: 2048,
  itemMinorVersion: 3,
  itemMajorVersion: 57
}

This structure resembles the browser DOM tree structure. And you can traverse it in a similar way.
Each node in the map has a parent, prevSibling, nextSibling and a children property. Each node also has firstChild and lastChild getters.

The children propery is an array of nodes (If children exists). If no prevSibling, nextSibling, firstChild or lastChild exists these will be null.

If you instead want a clean JavaScript object representation of the node tree you can call the asRawObject() method on the root node.

const reader = new OTBMReader(otbmFileBuffer);
const nodeTree = reader.getRootNode().asRawObject();