Skip to content

Anatoly03/pixelwalker.js

Repository files navigation

PixelWalker SDK

NPM | GitHub | Protocol

npm i --save pixelwalker.js
import "dotenv/config"
import { LobbyClient } from "pixelwalker.js"

export const client = LobbyClient.withToken(process.env.token);
export const game = await client.connection(process.env.world_id);

game.listen('playerChatPacket', ({ playerId, message }) => {
    if (message != '!ping') return;

    game.send('playerChatPacket', {
        message: `Pong, ${game.players[playerId].properties.username}!`,
    })
})

game.bind();

Testing in Local Development server

import { LobbyClient } from 'pixelwalker.js/localhost'

By setting the localhost flag (adding it to the import), the API server and Game server paths are derouted to the localhost ports equivalent.

Contribution

npm install             # Install `node_modules`
npm run generate-proto  # Build `.proto` files.
npm run build           # Execute this after making changes to the library.

Installing the node packages will also build the project into dist.