Elma Python Library

Advertise your levels, contests, sites etc.

Moderator: Moporators

Post Reply
sigveseb
Kuski
Posts: 6
Joined: 28 Nov 2014, 01:19

Elma Python Library

Post by sigveseb »

I started a python library for doing elma stuff, and made it open source in case it might be useful to someone.

GitHub: https://github.com/sigvef/elma

Elma Python Library

Elma Python Library is a python library for manipulating Elastomania files.
Currently, it supports simple level manipulation.

Documentation

Documentation is available at elma-python-library.readthedocs.org.

Installation

Code: Select all

pip install elma
Usage

Creating a simple level

Code: Select all

from elma.models import Level
from elma.models import Obj
from elma.models import Picture
from elma.models import Point
from elma.models import Polygon


level = Level()
level.name = 'My first level'
level.polygons = [
    Polygon([Point(-10, -10),
             Point(10, -10),
             Point(10, 10),
             Point(-10, 10)]),
]
level.objects = [
    Obj(Point(0, 0), Obj.START),
    Obj(Point(0, 10), Obj.FOOD, gravity=Obj.GRAVITY_UP),
    Obj(Point(0, 0), Obj.FLOWER),
]
level.pictures = [
    Picture(Point(2, 8), picture_name='flag'),
]
The above snippet defines a simple level that looks like this:

Image


Loading a level from file

Code: Select all

from elma.packing import unpack

with open('mylevel.lev') as f:
    level = unpack(f.read())
Saving a level to file

Code: Select all

from elma.packing import pack

level = ...

with open('mylevel.lev', 'w') as f:
    f.write(pack(level))
Contributing

Pull requests welcome!
User avatar
Mawane
Kuski
Posts: 3299
Joined: 15 Apr 2007, 01:05
Team: SV
Contact:

Re: Elma Python Library

Post by Mawane »

Getting the exact finish time of a replay with all possible digits possible?
Website || TT:41:45:64 || Team Image
Image[url=steam://friends/add/76561198025490048]Image[/url]
sigveseb
Kuski
Posts: 6
Joined: 28 Nov 2014, 01:19

Re: Elma Python Library

Post by sigveseb »

Not yet, the lib only does levels so far. Replays are on the todo list.
User avatar
gimp
Kuski
Posts: 1142
Joined: 28 May 2007, 08:47

Re: Elma Python Library

Post by gimp »

This seems like an extremely hard and time consuming way to make a level. So my question is is what potential practical uses does this program have?
God Bless America
User avatar
Lousku
Kuski
Posts: 2925
Joined: 5 Feb 2010, 00:25
Team: BAP
Location: expensive land of dads

Re: Elma Python Library

Post by Lousku »

gimp wrote:This seems like an extremely hard and time consuming way to make a level. So my question is is what potential practical uses does this program have?
Lev generators. Dunno what else.
then again i don't know anything
maybe easier not to think abouut alöl things thought than not things thought ... or something..=?
Domovoy
Kuski
Posts: 119
Joined: 9 Nov 2004, 04:56

Re: Elma Python Library

Post by Domovoy »

I didn't look at the code yet, but the idea of such library is very sane at least.

Everyone who ever wanted to write a program for elma had to implement his own lev and rec parsers, which is ridiculous, because such approach is prone to errors and is time-consuming and results in unprecedented amount of poorly-written chunks of nearly-identical code that all do the same.

Now at least for Python the problem is solved: import the library and you are ready to prototype your ideas. I will definitely use and maybe contribute. Kudos to sigveseb.
sigveseb
Kuski
Posts: 6
Joined: 28 Nov 2014, 01:19

Re: Elma Python Library

Post by sigveseb »

Version 0.4 is out now, with replay support.
Getting the exact finish time of a replay with all possible digits possible?
Yes.
Post Reply