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

tsinsim

v1.1.9

Published

An InSim library for Node.js (JavaScript runtime environment) with TypeScript support.

Downloads

47

Readme

TSINSIM

An InSim library for Node.js (JavaScript runtime environment) with TypeScript support. It allows you connect to Live for Speed Server over a TCP connection, share data between your program and game.

InSim compatibility

Fully compatible with InSim Version 9 (0.7F).

Requirements

This module requires Node.Js and TypeScript.

Installation

Install tsinsim in your Node.Js application:

npm install --save tsinsim

Usage

Connection

// import our module
import { InSim } from 'tsinsim';

// import our InSimFlags type for Flags below
import { InSimFlags } from 'tsinsim/enums';

const INSIM_VERSION = 9;

const insim = new InSim({
    Admin: '',                           // PASSWORD TO YOUR LFS HOST
    Flags: InSimFlags.ALL_MULTIPLAYER,   // FLAGS TO YOUR LFS HOST (MULTIPLAYER)
    Interval: 100,                       // TIME IN MS FOR IS_MCI (VEHICLE UPDATE PACKET). MINIMUM: 10 MS, RECOMMENDED: > 100 MS
    InSimVer: INSIM_VERSION,             // SEND INSIM VERSION TO LFS SERVER
    IName: 'host name',                  // APPLICATION NAME
    Prefix: 33                           // COMMAND PREFIX (33 -> !)                        
});

insim.connect({ 
    Host: '127.0.0.1',                  // HOST IP
    Port: 29999                         // HOST PORT
});

insim.on('connect', () => {
    console.log('InSim connecting...');
});

insim.on('connected', () => {
    console.log('InSim conected.');
});

insim.on('disconnect', () => {
    console.log('InSim disconnected.');
});

Receiving Packets

// lets import packet IS_MTC to send messages
import { IS_MTC } from 'tsinsim/packets';

insim.on('connected', () => {
    // SEND MESSAGE TO ALL CONNECTED PLAYERS
    const Packet = new IS_MTC();
    Packet.UCID = 255;
    Packet.Text = '^2Hello from the InSim Application!'
    insim.sendPacket(Packet);
});

Sending Packets

import { PacketType } from 'tsinsim';

// version info
insim.on(PacketType.ISP_VER, (data) => {
    console.log(data);
    /*
    IS_VER {
        Size: 5,
        Type: 2,
        ReqI: 1,
        Zero: 0,
        Version: '0.7E',
        Product: 'S3',
        InSimVer: 9,
        Spare: 0
    }
    */
});

Lets do something bigger together

// you already have insim connection above lets checkout this
// ... and you have IS_MTC imported as well

// new connection
insim.on(PacketType.ISP_NCN, (data) => {
    console.log(data);
    /*
    IS_NCN {
        Size: 14,
        Type: 18,
        ReqI: 1,
        UCID: 1,          // YOUR UNIQUE ID
        UName: 'TSINSIM', // YOUR LICENSE NAME
        PName: 'TSINSIM', // YOUR PLAYER NAME
        Admin: 1,         // ADMIN STATE
        Total: 2,
        Flags: 4,
        Sp3: 0
    }
    */

    // send message to the new player (shorter method)
    insim.sendPacket(new IS_MTC({ UCID: data.UCID, Text: '^7Welcome to the server a little adventurer! Use: !help' }));
});


// command handler
// we already have IS_MTC imported above but we don't have UserType for easier data handling
import { UserType } from 'tsinsim/enums';

insim.on(PacketType.ISP_MSO, (data) => {
    if(data.UserType == UserType.MSO_PREFIX) {
        const command = data.Text.substring(data.TextStart, data.Text.length);
        const isCommand = command.startsWith('!');

        if(isCommand && command == '!help') {
            insim.sendPacket(new IS_MTC({ UCID: data.UCID, Text: '^7You used command ^3!help ^7adventurer:' }));
            insim.sendPacket(new IS_MTC({ UCID: data.UCID, Text: '^7- This is example of module ^3tsinsim' }));
        }
    }
})