Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrgvsv/coggle-ecs
Parse Coggle maps for ECS data
https://github.com/mrgvsv/coggle-ecs
coggle ecs game-development mindmaps planning
Last synced: about 2 months ago
JSON representation
Parse Coggle maps for ECS data
- Host: GitHub
- URL: https://github.com/mrgvsv/coggle-ecs
- Owner: MrGVSV
- License: mit
- Created: 2019-12-27T10:18:25.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-27T14:35:52.000Z (about 5 years ago)
- Last Synced: 2024-05-01T17:29:18.160Z (8 months ago)
- Topics: coggle, ecs, game-development, mindmaps, planning
- Language: Python
- Homepage: https://pypi.org/project/coggle-ecs/
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# CoggleECS
CoggleECS is a small tool used to parse `.mm` files created at [coggle.it](https://coggle.it) for ECS data. It can then output ECS data as a tree or table. It can also be used to simply show links in your map.
For instance, Coggle creates links between nodes using a markdown format: `Player [#](#5d3adc) [#](#78959d)`. CoggleECS will replace those links with their respective nodes: `Player `.
## Installation
### Using pip [![PyPI version](https://badge.fury.io/py/coggle-ecs.svg)](https://badge.fury.io/py/coggle-ecs)
Run the following line in the terminal:
`pip install coggle-ecs`
### Using setup.py
Clone or download this repository and run the following line from the project's root directory:
`python setup.py install`
### Using Ctl+C
Copy and paste if you're daring enough.
## Setup & Usage
### 1. In Coggle
Outputting as tree data can work for any type of Coggle map (in fact you can just export the map itself as a text tree from Coggle if you don't care about replacing links).
However, outputting as a table requires a few things:
1. There **needs** to be nodes named each of the following (not case-sensitive):
* 'Entitities' or 'Entity' or 'E'
* 'Components' or 'Component' or 'C'
* 'Systems' or 'System' or 'S'
2. Entities should link **to** their respective Components.
3. Systems should link **to** their respective Components.Without the three nodes, the table will not render. And if those nodes exist but there are no links (or improper ones) then table will be be unfilled.
### 2. In CoggleECS
Once the above steps have been completed and your map has been filled, download it as a `.mm`. Then follow a similar program to below:
```python
from coggle_ecs import CoggleECS
my_map = CoggleECS('path/to/your/map.mm')
my_map.parse()
```You're all set to use `my_map` (or whatever you named it) to export in whatever format you prefer!
## Examples
### Input
```xml
```
### Output
```
Game Engine
Entities
Player
This is some description.
Alien
Components
Hostile
Transform
Move
Systems
Movement System
Enemy System
Art
``````
Hostile Transform Move
Type Name
Entity Player X X
Alien X X
System Movement System X X
Enemy System X
```## Output Functions
```python
output_text(self, outfile, delim=' ', indent=4, include_id=False)
```Output the map as a tree into a text file.
*outfile*: The output file
*delim*: Prepends node (Used to denote the level)
*indent*: Number of delims to print
*include_id*: Include the node's id at the end
```python
output_structure(self, outfile, indent=3, down='|', level='+', dash='-', space=' ')
```Output the map as a tree (in a folder structure format) into a text file.
*outfile*: The output file
*indent*: The number to indent each level
*down*: The character denoting a change in level
*level*: The character denoting a new parent
*dash*: The character bridging between the level and the node
*space*: The empty space between down characters
```python
output_table(self, outfile, use_ticks=True, true_tick='X', false_tick='')
```Output the map as a table into a text file.
*outfile*: The output file
*use_ticks*: Replace True and False with given strings
*true_tick*: Tick to replace True
*false_tick*: Tick to replace False
```python
output_csv(self, outfile, sep=',')
```Output the map as a table into a CSV file.
*outfile*: The output file
*sep*: The CSV separator
```python
output_json(self, outfile, orient='split')
```Output the map as a table into a JSON file.
*outfile*: The output file
*orient*: The format for the JSON (used internally by a pandas DataFrame)
## Other Functionality
You can also tap into your `CoggleECS` instance to get other data. Some examples:
```python
from coggle_ecs import CoggleECS
my_map = CoggleECS('path/to/your/map.mm')
my_map.parse()# Find a node by the beginning of its ID (returns first occurence)
node = my_map.find_by_id('1a2b3c')
# Get all the Entities, Components, or Systems
entities = my_map.get_entities()
components = my_map.get_components()
systems = my_map.get_systems()
# Get the ECS pandas DataFrame
my_map.create_table(include_systems=True)
df = my_map.table
```## Dependencies
This tool runs on Python 3 or later.
It also requires Pandas (the library, not the bear).