1.0.3 • Published 7 months ago

rustworld v1.0.3

Weekly downloads
-
License
BSD-2-Clause
Repository
github
Last release
7 months ago

RustWorldJS

Getting Started

Install the RustWorldJS package into your project

npm install rustworld

Usage

import * as rustWorld from "rustworld";

import * as fs from "fs";
import { dirname } from 'path';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));

fs.readFile(__dirname + '/../../test/test.map', function (err, fileContents) {
    let world = rustWorld.readMap(fileContents);

    rustWorld.writeMap(world).then(bytes => {
        // write bytes to file
    });
});

The package comes with Typescript definitions so if you are using Typescript you will be able to see every method and class available to use. To get started take a look at the examples for some code samples.

LZ4 Compression

The original Rust.World SDK and the game itself uses LZ4 compression for map reading and writing. They use a library called lz4net which is now outdated and has a custom implementation of LZ4. RustWorldJS recreates and uses that same custom implementation of LZ4.

This custom LZ4 format is a header for LZ4 data which means any LZ4 library can be used to read and write Rust maps if it can read and write the header. To recreate this custom LZ4 format in another language take a look at LZ4Reader.ts and worker.cts for an example on how the header is used.

The LZ4 library used in RustWorldJS is lz4js but modified to use a hashing method from lz4net

1.0.3

7 months ago

1.0.2

10 months ago

1.0.1

1 year ago

1.0.0

2 years ago