npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-openttd-admin

v0.2.4

Published

A Node.js Library for connecting to Openttd's admin interface.

Downloads

9

Readme

node-openttd-admin

A Node.js Library for connecting to Openttd's admin interface.

Preface

This module can be seen as an update to yorickvP/node-ottdadmin, however its completely rewritten to be a bit more tidy and standard, as well as working on more recent versions of node. I have kept the interface reasonably similar, however, its not a drop-in replacement.

Basic Usage

var ottd = require("node-openttd-admin"),
  ottdConnection =  new ottd.connection();

ottdConnection.connect("myserver.com", 3977);

ottdConnection.on('connect', function(){
  ottdConnection.authenticate("MyBot", "MyPass");
});
ottdConnection.on('welcome', function(data){
  ottdConnection.send_rcon("say \"hello world\"");
  ottdConnection.close();
});

Advanced Usage

Examples can be found in the examples/ folder

Functions

| Function Name | Description | parameters | | :------------------ | :--------------------------------------------------------------------------------------- | :----------------------------------- | |authenticate | Send and authentication request - this must be performed within 10 seconds of the server connecting |username - name of the client (can be null for a default) password - server admin password| |send_rcon | Send an rcon command |command - command to execute on the server | |send_chat | Send a chat message |action - an action from enums.Actions desttype - a destination from enums.DestTypes id - TODO: Lookup msg - message body| |send_update_frequency | Set a new update frequency |type - type of update (enums.UpdateTypes) frequency - frequency of update (enums.UpdateFrequencies) | |send_ping | Send a ping request |int32 - 32bit integer that will be returned with pong |

Events

| Event Name | Description | Options | | :------------------- | :--------------------------------------------------------------------------------------- | :----------------------------------- | |connect | Called when the tcp connection to the server is connected | none | |authenticate |Called when successfully authenticated. welcome is more useful for connection however |version- I have no idea TODO: Lookup| |welcome |Called when the server sends its "welcome packet", which contains info about the server |name - name of the server version - sematic version of the server. ie- 1.4.0-beta2 dedicated - 0 or 1 depending on whether the server is running as a dedicated server map - data about the map (seed, landscape, startdate, mapheight, mapwidth)| |newgame |fired when a new game starts |none| |shutdown |fired when a new game ends |none| |date |fired when information about the date is received |date - the current date| |clientjoin |fired when a client joins |id - id of joining client| |clientinfo |Fired when information about the client is received |id - id of the clientip - ip address of the clientname - username of the clientlang - language idjoindate - date the player joined the gamecompany - id of the company that the player is in| |clientupdate |Fired when an update from a client is received |id - id of the clientip - ip address of the clientname - username of the clientlang - language idjoindate - date the player joined the gamecompany - id of the company that the player is in| |clientquit |fired when a client quits |id - id of the client| |clienterror |Fired when a client has an error |id - id of the clienterr - error | |companyinfo |Fired when info about a company is received |id - company id name - company name manager - company manager colour - company primary colour protected - whether the company is password protected startyear - year of inaugaration isai - whether the company is ai or a human player| |companyupdate |Fired when an update happens to a company |id - company id name - company name manager - company manager colour - company primary colour protected - whether the company is password protected shares - who owns the 4 shares, this is an object with elements 1, 2, 3 and 4.| |companyremove |Fired when a company is deleted |id - company idreason - reason for deletion (enums.CompanyRemoveReasons)| |companyeconomy |fired on receiving information about the company's performance |id - company id money - money of the company loan - amount the company has borrowed income - income lastquarter - value, performance and cargo delivered (cargo) of the last quarter prevquarter - the same, but for the quarter before.| |companystats |Fired on receiving information about the assets of a company | vehicles - number of trains, lorries, busses, planes and ships that the company owns stations - number of stations of each type that the company owns| |chat |Fired on receiving a chat message |action - what action is included in the message (enums.Actions)desttype - where the message is aimed at (enums.DestTypes) id - message id message - message bodymoney - amount of money sent if action is GIVE_MONEY| |rcon |Fired on receiving the output of an rcon command |colour - what colour the message is displayed in output - output of the rcon | |rconend |Fired on receiving the end of an rcon command |command - the command that was sent to rcon |console |Fired on receiving output |origin - origin of the output output - body of the output| |pong |Fired on receiving ping reply |int - integer passed to send_pong|

Enums

There are several enums provided,these are taken almost directly from yorickvP/node-ottdadmin. This is just a list of them. Rather than listing all the entries here, please see enums.js

  • UpdateTypes
  • UpdateFrequencies
  • CompanyRemoveReasons
  • Actions
  • DestTypes
  • NetworkErrorCodes

Todo

  • ~~Write initial documentation~~
  • Look up unknowns in documentation
  • ~~Break up long switch into functions in another file~~
  • work out some way of doing tests
  • Proof read everything

Thanks To