# NMSlib

**master Branch** : ![](https://gitlab.com/Raum0x2A/nmslib/badges/master/pipeline.svg)

**develop Branch** : ![](https://gitlab.com/Raum0x2A/nmslib/badges/develop/pipeline.svg)

NMSlib is a GoLang package for dealing with converting Galactic coordinates to Portal codes and vice versa.

NMSlib also translates in game languages (Korvax, Gek Vy'Keen and Atlas) to english, and create portal banners.

## Installation

To install this module use `go get`


```bash
go get -u gitlab.com/Raum0x2A/nmslib
```

## Usage

**Example:**

```golang
package main

import (
    "fmt"

    "gitlab.com/Raum0x2A/nmslib"
)

func main() {
	portalcode := nmslib.RndPortal()
	galaticAddress, _ := nmslib.P2gc(portalcode)
	fmt.Printf("Random portal code: %s\n", portalcode)

	fmt.Printf("%s >> %s\n", portalcode, galaticAddress)
	nmslib.CreateBanner(portalcode, "./banners/"+portalcode+".png", 10)
	fmt.Printf("saving image to ./banners/%s.png\n", portalcode)

	fmt.Println("Translating \"KIHTYOMOLES\" from Korvax To English: " + nmslib.Translate{Word: "KIHTYOMOLES"}.Kor2Eng())
	korvax := nmslib.Translate{Word: "Contraband"}
	fmt.Println("Translating \"Contraband\" from English to Korvax: " + korvax.Eng2Kor())
}


```

### Creating a Glyph banner with CreateBanner()

This function takes 3 parameters:

* portalcode: 12 char hex string of portal location
* savename: Save location and name
* layout: 
  * 00 or 0 is horizontal in light mode
  * 01 or 1 is horizontal in dark mode
  * 11 is vertical in dark mode
  * 10 is vertical in light mode


**Example:**

Horizontal Layout for Galactic Hub [HUB10-6A Icarus Sun](https://nomanssky.gamepedia.com/HUB10-6A_Icarus_Sun) Eniwa 68/L3

```golang
nmslib.CreateBanner("006AFA556C30", "NewLennon.png", 0)
```

![](NewLennon.png)

Vertical layout for a random address

```golang
nmslib.CreateBanner(nmslib.RndPortal(), "ranportal.png", 11)
```

![](ranportal_scaled.png)

_Note: Images shown in readme.md have been scaled down in gimp._

_Original Vertical: 256x3072px_

_Original: Horizontal: 3072x256px_

### Converting Portal code to Galactic address with P2gc()

This function only takes 1 parameter and returns a string and error

* portalcode: 12 char hex string of portal glyphs

**Example:**

```golang
ga, _ := nmslib.P3gc("21F2F8EDB94D")
fmt.Println(ga)
```

Output:

``014C:0077:06DA:01F2``

### Converting Galactic coordinates to Portal codes with Gc2p()

This function only takes 1 parameter and returns a string and error

* galacticaddress: 16 char 4 block hex address

**Example:**

```golang
pc, _ := nmslib.P3gc("014C:0077:06DA:01F2")
fmt.Println(pc)
```

Output:

``21F2F8EDB94D``

## Translate Words

Supported languages

- Korvax
- Gek
- Vy'keen
- Atlas

### Translate Atlas to English with Atl2Eng()

This function takes only 1 parameter and returns a string

* Word: Any known Atlas word (ex. Paka)

**Example:**

```golang
fmt.Println(nmslib.Translate{Word: "Paka"}.Atl2Eng())
```

Output:

``Awake``

### Translate English to Korvax with Eng2Korvax()

This function takes only 1 parameter and returns a string

* engword: English word to attempt conversion

**Example:**

```golang
korvax := nmslib.Translate{Word: "Contraband"}
fmt.Println(korvax.Eng2Kor())
```

Output:

``Zelidovoso``


### Language commands

Gek:
- ``Translate{Word: string}.Gek2Eng()``
- ``Translate{Word: string}.Eng2Gek()``

Korvax:
- ``Translate{Word: string}.Kor2Eng()``
- ``Translate{Word: string}.Eng2Kor()``

Vy'keen:
- ``Translate{Word: string}.Vyk2Eng()``
- ``Translate{Word: string}.Eng2Vyk()``

Atlas:
- ``Translate{Word: string}.Atl2Eng()``
- ``Translate{Word: string}.Eng2Atl()``


## Random Portal address
### Create a random portal address

**Example:**

```golang
fmt.Println(nmslib.RndPortal())
fmt.Println(nmslib.RndPortal())
```

**Output:**

``10EFABDEA373``

``11EAB355FC8E``

## License
[MIT](COPYING)
