Haxball Headless Manager

Talk about haxball in here, maps, sides, players, tactics, anything related to the game.

Haxball Headless Manager

Postby saviola » August 14th, 2018, 1:21 pm

TLDR;

Paste the following into the dev console (only Chrome support for now):

Code: Select all
let s = document.createElement(`script`);s.src="https://haxplugins.tk/hhm.js";document.head.appendChild(s);


Then you can manually create the room or upload / link a config like this.

Solve the captcha, then you can upload headless scripts (switch to tab plugins -> add plugin, paste/upload headless script).

Useful for newcomers or people who want to run several scripts in parallel without merging them.

----

Long version:

Hello,

over the last few months, and with the help of salamini, I created a plugin system for the headless haxball host, the Haxball Headless Manager (HHM). When I started on this project I thought by the time I would be ready to publish it, others would have already done something similar (and maybe they have and I'm not aware?), so maybe this is not needed as much as I expected.

The first and foremost idea of this was to improve the usability of the headless host. I like Basro's balls to present a single unstyled HTML page throwing a documentation link (and later a room link) at you without anything else, and that in 2018 when people are throwing around terms like UX as if they were the holy grail.
Granted, it is still required to open the console once and paste something, haven't found a way around that yet, so many people will say "Well if I have to open the console and paste something, I might as well just paste the headless script that I'm always using and be done with it", and they are right.

But looking at the future, looking at the possibilities of this API, I expect the number, size, and complexity of these scripts to grow and eventually people will want to combine functionality of different scripts, or create modular scripts that can be combined into something bigger, depending on the needs of the user. And that's where I hope the HHM will come in, which, with the help of salamini's EventTrapper, allows several headless scripts to run in parallel, without the problem of overwriting event handlers. It also adds ways to have dependencies between these scripts (called plugins), and control the order in which the plugins are executed.

For now, this is more of a proof of concept, it exists but there's not a lot of plugins, but here's an example of how you could use the system in your headless scripts:

Code: Select all
let room = HBInit();
room.pluginSpec = {
  dependencies: [
    'saviola/commands',
  ]
};

room.onCommandAdmin1 = (player, arguments) => {
  // Write !admin somepw to get admin in the room, make sure to change this
  if (arguments[0] === 'somepw') {
    room.setPlayerAdmin(player.id, true);
  }

  return false;
}


What does this do? If someone writes "!admin somepw", he will be made admin and the chat line will not be displayed to others in the room. How does it work? First, we get a room instance: let room = HBInit();, we pass no parameters, because the room has already been created before, this is just a function looking similar to this:

Code: Select all
function HBInit() {
  return roomProxy;
}


Next up, we have the pluginSpec, which tells the HHM system about your plugin:

Code: Select all
room.pluginSpec = {
  dependencies: [
    'saviola/commands',
  ]
};


In this case, it tells the system that you need the plugin saviola/commands to be loaded. This plugin offers convenient event handlers to process commands.

Code: Select all
room.onCommandAdmin1 = (player, arguments) => {
  // Write !admin somepw to get admin in the room, make sure to change this
  if (arguments[0] === 'somepw') {
    room.setPlayerAdmin(player.id, true);
  }

  return false;
}


Here we register the event handler onCommandAdmin1, which is processed by the commands plugin, and tells it to call this function if someone writes the command "!admin" with one parameter. It conveniently passes you the player and an array of parameters.

You can also skip the whole UI part if you include your config file before the main HHM script and set trueHeadless to true in the config.

For more details on the usage and development, see the GitHub Repository and the main plugin repository (hosted by salamini, thanks).

Comments, thoughts, ideas? Next up I'll add some more features and then focus on creating useful plugins. Needless to say, it's still in the early stages of testing, so there will be many problems that I'll try to fix as I find them / as they are reported.
  • 51

User avatar
saviola
 
Posts: 144
News Articles: 0
Reputation: 660

Joined: December 9th, 2012, 5:08 pm


Re: Haxball Headless Manager

Postby Nana8 » August 14th, 2018, 1:30 pm

Nice to see that there are people like you who actually do something for this game :thumbup:

keep goin'
  • 0

lmao
User avatar
Nana8
 
Posts: 187
News Articles: 0
Reputation: 307

Joined: June 17th, 2013, 3:43 pm

Position: Defensive Midfielder


Return to General Haxball Discussion

Who is online

Users browsing this forum: No registered users and 20 guests

cron