Mopolauta

Elasto Mania board
It is currently 18 Oct 2017, 15:47

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Elma NPM package
PostPosted: 31 Jan 2017, 14:33 
Offline
Kuski
User avatar

Joined: 16 Jun 2002, 07:36
Posts: 708
Location: Oslo, Norway
Somewhat usable version of this is finally ready, source code here: https://github.com/elmadev/node-elma
NPM page: https://www.npmjs.com/package/node-elma (some retard using elma name for absolutely nothing, thx...)

It is pretty bad code all over and it's the first time trying to make promise-based functions and shit. Feel free to make changes if you think something sucks.

What?
If you dunno what it is based on name you probably do not care about this at all or will have any use for it, but it's a package for npm meant to be used with Node.js to read and write Elma files, both levels and replays.
Why?
Mostly for fun, but I think it's nice to have libraries to deal with Elma files for as many languages as possible and to have something everyone can use and contribute to instead of making million own shits. Also made with the intention of possibly being used with the new EOL site in the works, since it will be backed by Node.js.
How?
It is mostly pretty simple and intuitive I hope, and you can inspect the objects at any point to figure out what it contains anyway. There are some very simplified documentation in the links above too. But simple example could be like:
Code:
const elma = require('node-elma')

elma.Level.load('c:/idiotelmadir/lev/ret00044.lev').then(level => {
  // do things with 'level' here
}).catch(error => console.log(error))

The resulting object from that particular level would be something like:
Code:
{
  "version": "Elma",
  "link": 3072917268,
  "integrity": [
    -170445.64686103535,
    185596.64686103535,
    184364.64686103535,
    186930.64686103535
  ],
  "lgr": "DEFAULT",
  "name": "Unnamed",
  "ground": "ground",
  "sky": "sky",
  "polygons": [
    {
      "grass": false,
      "vertices": [
        {
          "x": -24,
          "y": -8
        },
        {
          "x": 20.390839694656492,
          "y": -8.562595419847328
        },
        {
          "x": 19.94198473282443,
          "y": 7.564122137404581
        },
        {
          "x": -15.48549618320611,
          "y": 7.33969465648855
        },
        {
          "x": -16.703816793893132,
          "y": 8.269465648854961
        },
        {
          "x": -20.26259541984733,
          "y": 7.5
        },
        {
          "x": -22.795419847328247,
          "y": 5.287786259541985
        },
        {
          "x": -24,
          "y": 2
        }
      ]
    }
  ],
  "objects": [
    {
      "x": 18.851908396946563,
      "y": 6.98702290076336,
      "type": "exit"
    },
    {
      "x": -23.56488549618321,
      "y": 1.7610687022900748,
      "type": "start"
    }
  ],
  "pictures": [],
  "top10": {
    "single": [
      {
        "time": 871,
        "name1": "skint0r",
        "name2": "idiot"
      }
    ],
    "multi": []
  }
}

Then there's some utility functions like formatting that time from top10 list (which are not actually in milliseconds or hundredths but actually a stupid string representation as a number, gg balazs..):
Code:
elma.util.formatTime(level.top10.single[0].time)

would then print: 00:08,71

Dunno what else explain since pretty obvious most things hopefully if you use brain little, but feel free to ask if unsure either here or irc or discord or wherever.

_________________
Prestigious member of 14.6x Tutor14 club


Top
 Profile  
 
 Post subject: Re: Elma NPM package
PostPosted: 31 Jan 2017, 22:03 
Offline
Kuski

Joined: 27 Jul 2013, 16:23
Posts: 235
Please add to http://wiki.elmaonline.net/Technical so that we can keep everything accessible and findable :) Can link mopo topic if want.

_________________
>>>ALL CONTRIBUTIONS<<<

DINO RUN 2 | FANCYPIC.EXE | SPINBOOSTING | Best public int replays


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group