1.0.0 • Published 11 months ago

@sheikah-converter/lib v1.0.0

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
-
Last release
11 months ago

@sheikah-converter/lib

Library to convert The Legend of Zelda: Breath of the Wild game saves between console formats (Wii U to Switch and viceversa)

Installation

npm install @sheikah-converter/lib

Usage (Node.js)

import fs from "node:fs/promises";
import path from "node:path";

import { getSaveType, convertSaveFile, getPrettySaveType } from '@sheikah-converter/lib';

const convert = async () => {
    await file = fs.read(path.resolve('directory', 'that', 'contains', 'save', '0', 'game_data.sav'));
    const { type, version } = getSaveType(file);

    console.log(getPrettySave(type), version) // prints "Switch, 1.6"

    const convertedBuffer = convertSaveFile(file);

    return writeFile(path.resolve('output', 'directory', '0', 'game_data.sav'), Buffer.from(convertedBuffer));
}

convert();

API

getSaveType(buffer) -> { type: number, version: string }

This function returns an object with the console (type) and version number for the save file. It does not work with trackblock files

ParameterDescriptionRequiredDefault
bufferBytes from a save file.true

convertSaveFile(buffer, trackblock) -> ArrayBuffer

Convert a save file from a console format to the other.

ParameterDescriptionRequiredDefault
bufferBytes from a save file.true
trackblockBoolean flag to use special logic when a file is of trackblock (Hero's Path functionality) typefalsefalse

getPrettySaveType(type) -> string

Get the name of the console as a string. This function is meant to be used with getSaveType.

ParameterDescriptionRequiredDefault
typeNumber that represents that represents the console in the SaveType enumtrue