mertushka / haxball.js

🎉 A powerful Node.JS library for interacting with the Haxball Headless Host API
https://github.com/haxball/haxball-issues/wiki/Headless-Host#api
MIT License
33 stars 4 forks source link
api haxball haxball-api haxball-bot haxball-bot-api haxball-headless haxball-headless-host haxballbot haxballjs headless javascript nodejs webrtc websocket wrtc

NPM Version NPM Monthly Downloads

License Last Commit Language Most Used Implementations Repository Size

Forks Stars Watches

haxball.js

haxball.js is a powerful Node.js module that allows you to easily interact with the Haxball Headless API.

🔖 Table Of Contents


🤔 How To Use

💻 Installing

npm install haxball.js

💻 Module Usage Example

// room.js

const HaxballJS = require("haxball.js");

HaxballJS.then((HBInit) => {
  // Same as in Haxball Headless Host Documentation
  const room = HBInit({
    roomName: "Haxball.JS",
    maxPlayers: 16,
    public: true,
    noPlayer: true,
    token: "YOUR_TOKEN_HERE", // Required
  });

  room.setDefaultStadium("Big");
  room.setScoreLimit(5);
  room.setTimeLimit(0);

  room.onRoomLink = function (link) {
    console.log(link);
  };
});

💻 (Optional) Proxy

Haxball has a limit of 2 rooms per IP. Therefore, you can use proxy with adding proxy: "<YOUR_PROXY_IP>" in your RoomConfig.

Example:

HBInit({
    ...
    proxy: "http://1.1.1.1:80",
});

💻 (Optional) TypeScript

From v2.1.0, the package has basic typings included. Typings are automatically imported alongside haxball.js package.

Install TypeScript and ts-node in your project:

npm install typescript --save-dev
npm install ts-node --save-dev

Name the file room.ts instead of room.js and use example room code from the previous section.

You may run the server with ts-node room.ts instead of node room.js. To make it runnable with npm start, add the alias to package.json:

// package.json

//...
  "scripts": {
    "start": "ts-node run.ts"
  }
//...

🚀 Technologies

Back To The Top


🌱 Minimal Requirements

Back To The Top


🎊 Features

Back To The Top


💡 How To Contribute

Contributions, issues and features requests are welcome!
📮 Submit PRs to help solve issues or add features
🐛 Find and report issues
🌟 Star the project

Back To The Top


🤗 Contributors

Back To The Top


🔏 License

Copyright © 2023 Mertushka mertushka@proton.me

This project is licensed by MIT License.

Back To The Top


This README was generated with 💟 by readme-template-generator