Skip to content

A Javascript library that is able to read and write map files for the game Rust

License

Notifications You must be signed in to change notification settings

Dezinater/RustWorldJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.js and worker.cjs 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

About

A Javascript library that is able to read and write map files for the game Rust

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published