Type definitions for creating Pixel Stories Maker plugins
npm install @ps-maker/plugin-apibash
npm install @pixelstories/plugin-api
or
pnpm add @pixelstories/plugin-api
or
yarn add @pixelstories/plugin-api
`
Usage
`typescript
import { definePlugin, defineEvent } from "@pixelstories/plugin-api";
const spawnItem = defineEvent({
name: "Spawn Item",
description: "Spawns an item at a position",
parameterDefs: {
x: { type: "number", description: "X position", defaultValue: 0 },
y: { type: "number", description: "Y position", defaultValue: 0 },
itemName: { type: "string", description: "Item name" }
},
execute(params, ctx) {
// params is fully typed: { x: number, y: number, itemName: string }
ctx.scene.add.sprite(params.x, params.y, params.itemName);
}
});
export default definePlugin({
name: "My Plugin",
description: "A sample plugin",
version: "1.0.0",
events: [spawnItem]
});
`
API
$3
Define a plugin with metadata and events.
$3
Define a plugin event with typed parameters.
$3
Context object passed to event handlers:
- game - The Phaser game instance
- scene - The current active scene
- player` - The player sprite