Library for parsing and writing Act files in NodeJS.
- Install Node.js which includes Node Package Manager
Install act-parser directly from NPM
npm install @csnvrag/act-parser
Or from Github
npm install https://github.com/csnv/act-parser.git
-
- fromFile(filepath)
static async function
- fromBuffer(buffer)
static function
- toFile(filepath)
async function
- toBuffer()
function
- header
string
- version
number
- events
array
- actions
array
- intervals
array
- fromFile(filepath)
-
- frames :
array
- frames :
-
- getEvent() :
function
- setEvent(eventName) :
function
- range1 :
array
- range2 :
array
- eventId :
number
- layers :
array
- anchorPoints :
array
- getEvent() :
ActFile is the top level class of this library. Along with the file information, actions, frames, events, etc can be accesed through this class.
Reads file specified in filepath
and returns an ActFile instance. This is the most straightforward method for reading act files.
Example:
import { ActFile } from "@csnvrag/act-parser";
const monsterFile = await ActFile.fromFile('./monster.act');
Parses a Buffer
with the contents of an .act file into an ActFile instance. In contrast to fromFile
, this method does not read files directly.
Example:
import { ActFile } from "@csnvrag/act-parser";
import { readFile } from "fs/promises";
const fileBuffer = await readFile('./monster.act');
const monsterFile = ActFile.fromBuffer(fileBuffer);
Writes current act file into a file, specified in filepath.
Example:
await monsterFile.toFile('./monster-copy.act');
Writes current act file into a buffer and returns the buffer for further processing. Example:
const buffer = monsterFile.toBuffer();
await writeFile('./monster-copy.act', buffer);
Header information of the file. Must be AC
.
Version of the file. Currently, this library supports from 0x200
to 0x205
.
Note: Act-parser saves files in version 0x205
.
Dynamic list of events. Each event is a string of max 40 characters.
Dynamic list of Actions.
Dynamic list of intervals, equal to the number of actions (one interval per action). Time in milliseconds after a certain action.
Action represents each direction in a sequence of frames.
Dynamic list of Frames
Frame object in a sequence of frames. Tightly linked with sprites.
Returns the name of the current frame event. Undefined
if none associated.
Assigns the label in eventName
to the frame. If such label does not exist in ActFile.events
, it's added automatically.
Dynamic array of Layers
0-based index of the assigned event of frame in ActFile.events
. -1
if no event is assigned.
Dynamic array of AnchorPoints
Layer representation of a sprite's bitmap.
Horizontal position in frame.
Vertical position in frame.
ID of sprite bitmap used in layer.
Bitflags of layer. Currently, only used for mirroring the layer on the y-axis.
Tint of the layer in RGBA form: [0, 0, 0, 0] to [255, 255, 255, 255]
Scale factor for width
Scale factor for height
Rotation of the layer around its center, in angle degrees.
The type of the sprite used from SPR. 0 == Palette sprite, 1 == RGBA sprite.
Width of the layer.
Height of the layer.
Anchor points of current frame.
Horizontal position in frame.
Vertical position in frame.
Attribute reference info