Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

att-string-transcoder

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

att-string-transcoder

Trancode integer strings for A Township Tale.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ATT String Transcoder

Allows you to decode A Township Tale's save strings for analysing, and encode JS objects into ATT save strings for spawning.

⚡️ Quick Start

Add this library to your project's dependencies:

$ npm install --save att-string-transcoder

Decoding a string

import { decodeString } from 'att-string-transcoder';

/**
 * You obtain an encoded save string by sending the `select tostring` console command.
 * See: https://docs.google.com/document/d/150PALdbZalylhkI4_iCL7Bl0X_rgvq80gJCUHik3z4I/edit?usp=sharing
 */
const encodedString = '23644,174,23644,{...very long...},2,';
const decodedString = decodeString(encodedString);
decodedString will contain:
const decodedString = {
  hash: 23644,
  size: 1392,
  prefab: {
    prefabObject: {
      hash: 23644,
      position: {
        x: -699.1250610351562,
        y: 128.15176391601562,
        z: 98.96036529541016
      },
      rotation: {
        x: -0.00007028286927379668,
        y: -0.06372569501399994,
        z: -0.0011925859143957496,
        w: 0.9979667663574219
      },
      scale: 1.0000009536743164
    },
    components: {
      Unknown: [],
      NetworkRigidbody: {
        position: {
          x: -699.1250610351562,
          y: 128.15176391601562,
          z: 98.96036529541016
        },
        rotation: {
          x: -0.00007028286927379668,
          y: -0.06372569501399994,
          z: -0.0011925859143957496,
          w: 0.9979667663574219
        },
        isKinematic: false,
        isServerSleeping: true,
        velocity: {
          x: 0,
          y: 0,
          z: 0
        },
        angularVelocity: {
          x: 0,
          y: 0,
          z: 0
        }
      },
      Pickup: {
        lastInteractorPlayerId: 1965324787
      },
      LiquidContainer: {
        canAddTo: false,
        canRemoveFrom: true,
        contentLevel: 0,
        hasContent: false,
        isCustom: false,
        presetHash: 0,
        customData: null
      },
      BasicDecay: {
        isDisabled: false,
        timelineEntry: 37654637031400
      }
    },
    embeddedEntities: {
      Unknown: [
        {
          hash: 21290,
          isAlive: true,
          components: {
            Unknown: [],
            Pickup: {
              lastInteractorPlayerId: 1965324787
            }
          }
        }
      ]
    },
    childPrefabs: []
  }
};

Encoding a string

First, create a blade prefab object:
import { Prefab, PrefabHash, PhysicalMaterialPartHash } from 'att-string-transcoder';

const blade: Prefab = {
  prefabObject: {
    hash: PrefabHash.Large_Longsword_Blade
  },
  components: {
    PhysicalMaterialPart: {
      materialHash: PhysicalMaterialPartHash.EvinonSteelAlloy
    },
    DurabilityModule: {
      integrity: 0.01
    }
  }
};
Then, create a guard prefab object:
import { Prefab, PrefabHash, PhysicalMaterialPartHash } from 'att-string-transcoder';

export const guard: Prefab = {
  prefabObject: {
    hash: PrefabHash.Large_Guard_Rectangle
  },
  components: {
    PhysicalMaterialPart: {
      materialHash: PhysicalMaterialPartHash.Copper
    },
    DurabilityModule: {
      integrity: 0.01
    }
  },
  childPrefabs: [
    {
      parentHash: 51896,
      prefab: blade
    }
  ]
};
Finally, create a handle prefab object:
import { Prefab, PrefabHash } from 'att-string-transcoder';

const position = {
  x: -701,
  y: 128.2,
  z: 100
};

export const handle: Prefab = {
  prefabObject: {
    hash: PrefabHash.Handle_Short,
    position
  },
  components: {
    NetworkRigidbody: {
      position
    }
  },
  childPrefabs: [
    {
      parentHash: 6136,
      prefab: guard
    }
  ]
};

Encode the hierarchical prefab object to obtain a string for spawning:

import { createString } from 'att-string-transcoder';

/* ... defined prefab objects ... */

/**
 * You spawn an encoded save string by sending the `spawn string-raw` console command.
 * See: https://docs.google.com/document/d/150PALdbZalylhkI4_iCL7Bl0X_rgvq80gJCUHik3z4I/edit?usp=sharing
 */
const encodedSword = createString(handle);
encodedSword will contain:
42230,252,42230,3291430912,1124086579,1120403456,0,0,0,1065353216,1065353216,2290978823,418,3291430912,1124086579,1120403456,0,0,0,1065353216,0,0,0,0,0,0,0,0,536871679,1163,0,0,0,0,0,0,133169152,133169152,34023564,2684354564,2523,1307670851,3758096388,126122721,1073741824,0,268438699,2147487155,3221225472,0,0,0,0,0,66584576,66584576,17011782,1342177282,1968,3875060897,4026531842,63061360,2684354560,0,0,|3,2290978823,1,272188517,1,1871432223,1,

Keywords

FAQs

Package last updated on 26 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc