Giter Site home page Giter Site logo

fossabot / ffxiv-overlay-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dsrkafuu/ffxiv-overlay-api

0.0 2.0 0.0 474 KB

Build your own modern FFXIV overlay with npm.

Home Page: https://www.npmjs.com/package/ffxiv-overlay-api

License: MIT License

JavaScript 89.27% HTML 10.73%

ffxiv-overlay-api's Introduction

πŸ—‘ ffxiv-overlay-api πŸ›‘

BADGE BADGE BADGE BADGE FOSSA Status

Build your own modern FFXIV overlay with npm.

This library needs to be used along with ngld/OverlayPlugin.

Table of Contents

Installation

You can install it from npm registry:

npm install ffxiv-overlay-api --save

Or import the library from jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/overlay.min.js"></script>

Usage

After installation, you can import the library:

import OverlayAPI from 'ffxiv-overlay-api';
const overlay = new OverlayAPI();

Note that this library only works in browser.

You can also pass options to constructor:

const overlay = new OverlayAPI({
  extendData: true,
  silentMode: false,
});

Then you can add bunch of different listeners.

const overlay = new OverlayAPI();
overlay.addListener('CombatData', (data) => {
  console.log('Listener of CombatData', data);
});
overlay.addListener('ChangeZone', (data) => {
  console.log('Listener of ChangeZone', data);
});

Call this function once you’re done adding all of your listeners:

overlay.startEvent();

Once this function has been called, OverlayPlugin will start sending events. Some events will be raised immediately with current state information like ChangeZone or ChangePrimaryPlayer.

After that, put the URL of your overlay into OverlayPlugin, or use the WebSocket URL when enabled. Checkout the index.html for example usage, you can download this file and load it from the OverlayPlugin. Enable WebSocked in your plugin and add ?OVERLAY_WS=ws://127.0.0.1:[port]/ws after you overlay URL to access the WebSocket server.

Checkout Development section for more details.

Options

Option Default Description
extendData false Parse and add cleaner data to listeners of CombatData
silentMode false For production use, do not log all API stats info

API

You can find all events available in https://ngld.github.io/OverlayPlugin/devs/event_types.

OverlayAPI.addListener(event, cb)

Add an event listener.

  • @param {String} event Event to listen
  • @param {Function} cb Callback function

OverlayAPI.removeListener(event, cb)

Remove a listener.

  • @param {String} event Event type which listener belongs to
  • @param {Function} cb Function of which listener to remove

OverlayAPI.removeAllListener(event)

Remove all listener of one event type.

  • @param {String} event Event type which listener belongs to

OverlayAPI.getAllListener(event)

Get all listeners of a event.

  • @param {String} event Event type which listener belongs to

OverlayAPI.startEvent()

Start listening event.

OverlayAPI.endEncounter()

Ends current encounter and save it.

OverlayAPI.callHandler(msg)

This function allows you to call an overlay handler. These handlers are declared by Event Sources (either built into OverlayPlugin or loaded through addons like Cactbot). Returns a Promise.

  • @param {Object} msg Message send to OverlayPlugin

OverlayAPI.simulateData(fakeData)

Pass some fake data object to start simulation, or do not pass params to disable simulation.

Development

Clone this repo, then:

npm install
npm start

You can access the test overlay at http://localhost:5000/test/ and http://localhost:5000/test/?OVERLAY_WS=ws://127.0.0.1:[port]/ws.

Remember to run npm run build before release commit.

Contributon

Please use the .prettierrc at the root of the project along with Prettier default settings to format your code.

Annotations

Β© 2020 DSRKafuU Twitter @amzrk2

License

FOSSA Status

ffxiv-overlay-api's People

Contributors

fossabot avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.