npm i --save pixelwalker.js
import "dotenv/config";
import { APIClient, Block } from "pixelwalker.js";
const client = APIClient.withToken(process.env.TOKEN!)!;
const game = await client.createGame("r450e0e380a815a");
game.listen("Init", () => {
console.log("Init!");
});
game.bind();
Per default, this library will not work in the browser without downloading the polyfill node modules, below is an example how you can achieve this using the vite-plugin-node-polyfills module, which will help with bundling node-native, which this library uses: events
npm i --save pixelwalker.js
npm i --save-dev vite-plugin-node-polyfills
// vite.config.ts
import { defineConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
export default defineConfig({
plugins: [
nodePolyfills({
include: ['events'],
globals: { process: true },
}),
],
})
npm install # Install `node_modules`
npm run build # Execute this after making changes to the library.
Installing the node packages will also build the project into dist.