npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pa-prefab

v2.0.0

Published

Reads and generates Project Arrhythmia prefabs procedurally

Downloads

4

Readme

Reads and generates Project Arrhythmia prefabs procedurally

GitHub repository: https://github.com/PA-Toolkit/pa-prefab

Install

npm install pa-prefab

Build

npm run build

Usage

Importing

Node.js

const { Prefab, PrefabType } = require("pa-prefab");

or

import { Prefab, PrefabType } from "pa-prefab";

Browser

<head>
    <script type="text/javascript" src="path/to/pa-prefab.js"/>
</head>

<script>
    const Prefab = PAPrefab.Prefab;
    const PrefabType = PAPrefab.PrefabType;
</script>

Creating a prefab

It is recommended to use the CreatePrefab(string, PrefabType) function to create a new prefab.

const { Prefab, PrefabType } = require("pa-prefab");

let myPrefab = new Prefab("Hello Prefab Toolkit!", PrefabType.Misc1);

Creating an object

To create an object, make a new object with new PAObject(name, Prefab) and add it to the prefab with Prefab.addObject(PAObject).

const { Prefab, PrefabType } = require("pa-prefab");
const { PAObject } = require("pa-common");

let myPrefab = new Prefab("Hello Prefab Toolkit!", PrefabType.Misc1);
let myObject = new PAObject("Hello Object!", myPrefab);
myPrefab.addObject(myObject);

Modifying the object

Setting the object's name

myObject.name = "Hello world!";

Toggling position/scale/rotation parenting

myObject.positionParenting = true;
myObject.scaleParenting = false;
myObject.rotationParenting = true;

Similarly, for parent offset

myObject.positionParentOffset = 0.0;
myObject.scaleParentOffset = 1.0;
myObject.rotationParentOffset = 2.0;

Changing render depth

myObject.renderDepth = 5; // This should be an integer!

Changing object type

const { ObjectType } = require("pa-common");

myObject.objectType = ObjectType.Helper;

Changing object shape

const { Shape } = require("pa-common");

myObject.shape = Shape.Circle;

Changing object sub-shape

const { CircleOption } = require("pa-common");

myObject.shapeOption = CircleOption.HalfHollow;

Changing object text

myObject.text = "The quick brown fox jumps over the lazy dog."; // Note: This will be ignored unless your object shape is Text.

Changing object auto kill type

const { AutoKillType } = require("pa-common");

myObject.autoKillType = AutoKillType.Fixed;

Changing object auto kill offset

myObject.autoKillOffset = 5.0;

Changing object origin

myObject.originX = 0.5;
myObject.originY = 0.5;

Changing editor locked/collapsed state and bin/layer

myObject.editorLocked = false;
myObject.editorCollapse = true;
myObject.editorBin = 1;
myObject.editorLayer = 0;

Animating the object

There are four lists of different keyframe types inside the object. Each list is empty initially. You can add keyframes to those list to animate them. Note that there should be at least one keyframe per list.

myObject.pushPosition(0.0, 0.0, 0.0);
myObject.pushScale(0.0, 1.0, 1.0);
myObject.pushRotation(0.0, 0.0);
myObject.pushColor(0.0, 0);

Building the prefab

You can convert the prefab to a JSON string to write it to a file.

const { fs } = require("fs");

fs.writeFileSync("my_new_prefab.lsp", prefab.toString());

Reading an existing prefab

You can read an existing prefab from a string.

const { fs } = require("fs");
const { Prefab, PrefabType } = require("pa-prefab");

let json = JSON.parse(jsonStr);
let prefab = new Prefab("", PrefabType.Bombs); // will be overriden by fromJson!
prefab.fromJson(json);

Run tests

npm run test

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator