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

niod-core

v0.1.0-beta.3

Published

NIOD is a JS API for DCS World, NIOD-core is the core lib of the NIOD ecosystem. It uses a socket to communicate with a LUA library

Downloads

7

Readme

Latest build CircleCI

NIOD Logo

NIOD-core

Discord logo Join us on discord !

Introduction

NIOD-core is a npm package that lets you connect to DCS World using a socket. Once connected, it offers a variety of functionalities :

  • Events: You can listen to events from DCS World
  • Functions: You can call functions from the DCS Mission Scripting API

This is a pretty low level package, mission makers should probably not use NIOD-core directly but a package that uses NIOD-core to get higher level functionalities. My plan is to make one in the near future.

How does this work ?

A socket is created in the mission scripting environment, NIOD-core connects to it and sends / receives commands discribing events and functions.

The nodejs server stores callbacks linked to a callback id, this id is passed to the lua server which pass it back with the returned data. The dispatcher will then execute the right stored callback.

Here's a basic example

const { initNiod, getGroups, addEventHandler, COALITIONS, EVENTS } = require("niod-core");
initNiod().then(async () => {
  // Log information on all the groups in the blue coalition
  console.log(await getGroups(COALITIONS.BLUE));
  // Log position of new added marks
  addEventHandler(EVENTS.EventMarkAdded, (event) => {
	  console.log("A mark was added at position", event.pos);
  })
});

Instalation

Unsanitize the require function

Niod requires DCS to import some functionalities from LUA so it can create a socket and access the OS time API, you'll need to "unsanitize" it. To do so go into your DCS installation folder DCS World\Scripts\MissionScripting.lua and edit these line.

do
	sanitizeModule('os')
	sanitizeModule('io')
	sanitizeModule('lfs')
	require = nil
	loadlib = nil
end

to


do
	--sanitizeModule('os')
	sanitizeModule('io')
	sanitizeModule('lfs')
	--require = nil
	loadlib = nil
end

Mission Editor

Then you need to create a mission that loads the NIOD lua file found in the "script" folder.

And there you go ! You're all set, you can import niod in your project and start the server using

const { initNiod } = require("niod-core");
initNiod().then(() => {
  // your mission code goes here
});

and start coding !

Typescript support

Niod is written in typescript, so the npm package is shipped with all the type declarations. Which means auto-completion depending on your code editor

API

You can find the complete docs here

Since there is a lot of documented functions you probably won't need, here are links to:

Guides

I'll be writing guides with examples, links will be down below

Special thanks

Thanks to Drex from Dynamic DCS for all the help on sockets, go check his server out