Compare commits
28 Commits
v0.3.0-bet
...
v0.3.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8945530dbf | ||
|
|
73fa913292 | ||
|
|
47db5b0767 | ||
|
|
4aef1e390a | ||
|
|
284313eacc | ||
|
|
faf72d1f7a | ||
|
|
7c5d4b5ce8 | ||
|
|
ad42c6bb04 | ||
|
|
5ca88596ff | ||
|
|
53d85d958b | ||
|
|
ea51873fe3 | ||
|
|
90d743286f | ||
|
|
bc0c364dcc | ||
|
|
43496932ef | ||
|
|
d6bfa643a9 | ||
|
|
877517b923 | ||
|
|
ccbd68aee8 | ||
|
|
5077876106 | ||
|
|
9682494ce1 | ||
|
|
87bec565f1 | ||
|
|
a7069dce7e | ||
|
|
bc4e334ecd | ||
|
|
9358727075 | ||
|
|
3449ae3bf3 | ||
|
|
023eab03b2 | ||
|
|
5f4414df03 | ||
|
|
57a1d729dd | ||
|
|
67db2e32ef |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
assets/
|
||||||
9
.gitlab-ci.yml
Normal file
9
.gitlab-ci.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
stages:
|
||||||
|
- test
|
||||||
|
|
||||||
|
test:
|
||||||
|
stage: test
|
||||||
|
image: golang:1.16.3
|
||||||
|
script:
|
||||||
|
- go test
|
||||||
|
|
||||||
112
README.md
112
README.md
@@ -1,9 +1,12 @@
|
|||||||
# NMSlib
|
# NMSlib
|
||||||
|
|
||||||
|
**master Branch** : 
|
||||||
|
|
||||||
|
**develop Branch** : 
|
||||||
|
|
||||||
NMSlib is a GoLang package for dealing with converting Galactic coordinates to Portal codes and vice versa.
|
NMSlib is a GoLang package for dealing with converting Galactic coordinates to Portal codes and vice versa.
|
||||||
|
|
||||||
NMSlib also translates known Korvax words to English and back.
|
NMSlib also translates in game languages (Korvax, Gek Vy'Keen and Atlas) to english, and create portal banners.
|
||||||
- Gek, Vykeen, etc will be added in the future
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -11,7 +14,7 @@ To install this module use `go get`
|
|||||||
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go get -u gitlab.com/bradley.richins/nmslib
|
go get -u gitlab.com/Raum0x2A/nmslib
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -24,22 +27,23 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"gitlab.com/bradley.richins/nmslib"
|
"gitlab.com/Raum0x2A/nmslib"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
portalcode := "006afa556c30"
|
portalcode := "21F2F8EDB94D"
|
||||||
tstvar, err := nmslib.P2gc(portalcode)
|
tstvar, err := nmslib.P2gc(portalcode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Printf("Input:\t%s\nExpecting:\t042F:0079:0D55:006A\nHave:\t%s\n", portalcode, tstvar)
|
fmt.Printf("Input:\t%s\nExpecting:\t014C:0077:06DA:01F2\nHave:\t%s\n", portalcode, tstvar)
|
||||||
|
|
||||||
nmslib.CreateBanner(portalcode, "NewLennon.png", 0)
|
nmslib.CreateBanner(portalcode, "NewLennon.png", 0)
|
||||||
|
nmslib.CreateBanner(RndPortal(), "Random.png", 0)
|
||||||
|
|
||||||
fmt.Println(Translate{"KIHTYOMOLES"}.Kor2Eng())
|
fmt.Println(nmslib.Translate{"KIHTYOMOLES"}.Kor2Eng())
|
||||||
korvax := Translate{"Contraband"}
|
korvax := nmslib.Translate{"Contraband"}
|
||||||
fmt.Println(korvax.Eng2Kor())
|
fmt.Println(nmslib.korvax.Eng2Kor())
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -50,67 +54,95 @@ This function takes 3 parameters:
|
|||||||
|
|
||||||
* portalcode: 12 char hex string of portal location
|
* portalcode: 12 char hex string of portal location
|
||||||
* savename: Save location and name
|
* savename: Save location and name
|
||||||
* Horizontal/Vertical layout: 0 is horizontal, 1 is vertical
|
* 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:**
|
**Example:**
|
||||||
|
|
||||||
Horizontal Layout for Galactic Hub [HUB10-6A Icarus Sun](https://nomanssky.gamepedia.com/HUB10-6A_Icarus_Sun) Eniwa 68/L3
|
Horizontal Layout for Galactic Hub [HUB10-6A Icarus Sun](https://nomanssky.gamepedia.com/HUB10-6A_Icarus_Sun) Eniwa 68/L3
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
nmslib.CreateBanner("006afa556c30", "NewLennon.png", 0)
|
nmslib.CreateBanner("006AFA556C30", "NewLennon.png", 0)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
Vertical layout for a random address
|
||||||
|
|
||||||
|
```golang
|
||||||
|
nmslib.CreateBanner(nmslib.RndPortal(), "ranportal.png", 11)
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
_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()
|
### Converting Portal code to Galactic address with P2gc()
|
||||||
|
|
||||||
This function only takes 1 parameter and returns a string
|
This function only takes 1 parameter and returns a string and error
|
||||||
|
|
||||||
* portalcode: 12 char hex string of portal glyphs
|
* portalcode: 12 char hex string of portal glyphs
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
ga, _ := nmslib.P3gc("006afa556c30")
|
ga, _ := nmslib.P3gc("21F2F8EDB94D")
|
||||||
fmt.Println(ga)
|
fmt.Println(ga)
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
``042F:0079:0D55:006A``
|
``014C:0077:06DA:01F2``
|
||||||
|
|
||||||
### Converting Galactic coordinates to Portal codes with Gc2p()
|
### Converting Galactic coordinates to Portal codes with Gc2p()
|
||||||
|
|
||||||
This function only takes 1 parameter and returns a string
|
This function only takes 1 parameter and returns a string and error
|
||||||
|
|
||||||
* galacticaddress: 16 char 4 block hex address
|
* galacticaddress: 16 char 4 block hex address
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
pc, _ := nmslib.P3gc("042F:0079:0D55:006A")
|
pc, _ := nmslib.P3gc("014C:0077:06DA:01F2")
|
||||||
fmt.Println(pc)
|
fmt.Println(pc)
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
``006AFA556C30``
|
``21F2F8EDB94D``
|
||||||
|
|
||||||
### Translate Korvax to English with Korvax2Eng()
|
## 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
|
This function takes only 1 parameter and returns a string
|
||||||
|
|
||||||
* korvaxword: Any known Korvaxen word (ex. eapoluch)
|
* Word: Any known Atlas word (ex. Paka)
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
fmt.Println(Translate{"KIHTYOMOLES"}.Kor2Eng())
|
fmt.Println(nmslib.Translate{"Paka"}.Atl2Eng())
|
||||||
```
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
``CONTRABAND``
|
``Awake``
|
||||||
|
|
||||||
### Translate English to Korvax with Eng2Korvax()
|
### Translate English to Korvax with Eng2Korvax()
|
||||||
|
|
||||||
@@ -121,7 +153,7 @@ This function takes only 1 parameter and returns a string
|
|||||||
**Example:**
|
**Example:**
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
korvax := Translate{"Contraband"}
|
korvax := nmslib.Translate{"Contraband"}
|
||||||
fmt.Println(korvax.Eng2Kor())
|
fmt.Println(korvax.Eng2Kor())
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -129,5 +161,41 @@ Output:
|
|||||||
|
|
||||||
``Zelidovoso``
|
``Zelidovoso``
|
||||||
|
|
||||||
|
|
||||||
|
### Language commands
|
||||||
|
|
||||||
|
Gek:
|
||||||
|
- ``Translate{string}.Gek2Eng()``
|
||||||
|
- ``Translate{string}.Eng2Gek()``
|
||||||
|
|
||||||
|
Korvax:
|
||||||
|
- ``Translate{string}.Kor2Eng()``
|
||||||
|
- ``Translate{string}.Eng2Kor()``
|
||||||
|
|
||||||
|
Vy'keen:
|
||||||
|
- ``Translate{string}.Vyk2Eng()``
|
||||||
|
- ``Translate{string}.Eng2Vyk()``
|
||||||
|
|
||||||
|
Atlas:
|
||||||
|
- ``Translate{string}.Atl2Eng()``
|
||||||
|
- ``Translate{string}.Eng2Atl()``
|
||||||
|
|
||||||
|
|
||||||
|
## Random Portal address
|
||||||
|
### Create a random portal address
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```golang
|
||||||
|
fmt.Println(nmslib.RndPortal())
|
||||||
|
fmt.Println(nmslib.RndPortal())
|
||||||
|
```
|
||||||
|
|
||||||
|
**Output:**
|
||||||
|
|
||||||
|
``10EFABDEA373``
|
||||||
|
|
||||||
|
``11EAB355FC8E``
|
||||||
|
|
||||||
## License
|
## License
|
||||||
[MIT](COPYING)
|
[MIT](COPYING)
|
||||||
|
|||||||
@@ -8,11 +8,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The maths are all thanks to:
|
Xainesworld Video: https://www.youtube.com/watch?v=xmZbkTahw4w
|
||||||
Xainesworld
|
Fandom Wiki: https://nomanssky.fandom.com/wiki/Portal_address
|
||||||
- YT Channel - https://www.youtube.com/channel/UCzTB8EBVJWkzJi2sQjdBv9g
|
|
||||||
- Video: https://www.youtube.com/watch?v=xmZbkTahw4w
|
|
||||||
- Website: https://www.xainesworld.com/
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -63,7 +60,7 @@ func P2gc(p string) (gc string, err error) {
|
|||||||
gc = fmt.Sprintf("%04X:%04X:%04X:%04X", coord[3], coord[1], coord[2], coord[0])
|
gc = fmt.Sprintf("%04X:%04X:%04X:%04X", coord[3], coord[1], coord[2], coord[0])
|
||||||
|
|
||||||
} else { // if len(p) != 12 return an error
|
} else { // if len(p) != 12 return an error
|
||||||
return "", errors.New("A 12char HEX string is required. example: 006afa556c30")
|
return "", errors.New("a 12char HEX string is required. example: 006afa556c30")
|
||||||
}
|
}
|
||||||
return // return formated string
|
return // return formated string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/nfnt/resize"
|
|
||||||
|
|
||||||
gim "github.com/ozankasikci/go-image-merge"
|
gim "github.com/ozankasikci/go-image-merge"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,14 +16,17 @@ var portalex string
|
|||||||
Portal Glyph hex string
|
Portal Glyph hex string
|
||||||
var savename string
|
var savename string
|
||||||
Output name of PNG file
|
Output name of PNG file
|
||||||
var vopt int
|
var opt int
|
||||||
1 enables vertical banner
|
00 sets horizontal banner in light mode
|
||||||
0 enables horizontal banner
|
10 sets vertical banner in light mode
|
||||||
|
01 sets horizontal banner in dark mode
|
||||||
|
11 sets vertical banner in dark mode
|
||||||
*/
|
*/
|
||||||
func CreateBanner(portalhex string, savename string, vopt int) {
|
func CreateBanner(portalhex string, savename string, opt int) {
|
||||||
var err error
|
var err error
|
||||||
var GlyphHex [12]int64
|
var GlyphHex [12]int64
|
||||||
var glyphImg [12]string
|
var glyphImg [12]string
|
||||||
|
var mode string
|
||||||
var vert int
|
var vert int
|
||||||
var horz int
|
var horz int
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ func CreateBanner(portalhex string, savename string, vopt int) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(tempdir)
|
//defer os.RemoveAll(tempdir)
|
||||||
|
|
||||||
// verify len of portalhex
|
// verify len of portalhex
|
||||||
if len(portalhex) == 12 {
|
if len(portalhex) == 12 {
|
||||||
@@ -45,9 +46,25 @@ func CreateBanner(portalhex string, savename string, vopt int) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set options
|
||||||
|
if opt == 00 { // set vertical rendering in light mode
|
||||||
|
vert, horz = 12, 1
|
||||||
|
mode = "light"
|
||||||
|
} else if opt == 01 { // set vertival in dark mode
|
||||||
|
vert, horz = 12, 1
|
||||||
|
mode = "dark"
|
||||||
|
} else if opt == 11 { // set horizontal rendering in dark mode
|
||||||
|
vert, horz = 1, 12
|
||||||
|
mode = "dark"
|
||||||
|
} else { // set horizontal rendering in light mode (classic/default)
|
||||||
|
vert, horz = 1, 12
|
||||||
|
mode = "light"
|
||||||
|
}
|
||||||
|
|
||||||
// assign image location of its glyph hex value to an array of strings
|
// assign image location of its glyph hex value to an array of strings
|
||||||
for j := 0; j < len(glyphImg); j++ {
|
for j := 0; j < len(glyphImg); j++ {
|
||||||
glyphImg[j] = fmt.Sprintf("glyphs/GLYPH-%X.png", GlyphHex[j])
|
glyphImg[j] = fmt.Sprintf("assets/glyphs/%s/PORTALSYMBOL.%X.png", mode, GlyphHex[j])
|
||||||
}
|
}
|
||||||
// pull images need from glyph.go and saved them to ./glyphs/
|
// pull images need from glyph.go and saved them to ./glyphs/
|
||||||
for k := 0; k < len(glyphImg); k++ {
|
for k := 0; k < len(glyphImg); k++ {
|
||||||
@@ -55,47 +72,39 @@ func CreateBanner(portalhex string, savename string, vopt int) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
_, err2 := os.Stat(tempdir + "/glyphs/")
|
_, err2 := os.Stat(tempdir + "/assets/glyphs/" + mode + "/")
|
||||||
if os.IsNotExist(err2) {
|
if os.IsNotExist(err2) {
|
||||||
errDir := os.MkdirAll(tempdir+"/glyphs", 0755)
|
errDir := os.MkdirAll(tempdir+"/assets/glyphs/"+mode, 0755)
|
||||||
if errDir != nil {
|
if errDir != nil {
|
||||||
panic(errDir)
|
panic(errDir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// fmt.Println(tempdir + "/" + glyphImg[k]) // for debugging only
|
||||||
err = ioutil.WriteFile(tempdir+"/"+glyphImg[k], []byte(data), 0644)
|
err = ioutil.WriteFile(tempdir+"/"+glyphImg[k], []byte(data), 0644)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// load images for processing using github.com/ozankasikci/go-image-merge
|
||||||
|
grids := []*gim.Grid{
|
||||||
|
{ImageFilePath: tempdir + "/" + glyphImg[0]}, {ImageFilePath: tempdir + "/" + glyphImg[1]},
|
||||||
|
{ImageFilePath: tempdir + "/" + glyphImg[2]}, {ImageFilePath: tempdir + "/" + glyphImg[3]},
|
||||||
|
{ImageFilePath: tempdir + "/" + glyphImg[4]}, {ImageFilePath: tempdir + "/" + glyphImg[5]},
|
||||||
|
{ImageFilePath: tempdir + "/" + glyphImg[6]}, {ImageFilePath: tempdir + "/" + glyphImg[7]},
|
||||||
|
{ImageFilePath: tempdir + "/" + glyphImg[8]}, {ImageFilePath: tempdir + "/" + glyphImg[9]},
|
||||||
|
{ImageFilePath: tempdir + "/" + glyphImg[10]}, {ImageFilePath: tempdir + "/" + glyphImg[11]},
|
||||||
|
}
|
||||||
|
|
||||||
|
// create new image from grids
|
||||||
|
rgba, err := gim.New(grids, vert, horz).Merge()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// save the output to png
|
||||||
|
file, err := os.Create(savename)
|
||||||
|
err = png.Encode(file, rgba)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// load images for processing using github.com/ozankasikci/go-image-merge
|
|
||||||
grids := []*gim.Grid{
|
|
||||||
{ImageFilePath: tempdir + "/" + glyphImg[0]}, {ImageFilePath: tempdir + "/" + glyphImg[1]},
|
|
||||||
{ImageFilePath: tempdir + "/" + glyphImg[2]}, {ImageFilePath: tempdir + "/" + glyphImg[3]},
|
|
||||||
{ImageFilePath: tempdir + "/" + glyphImg[4]}, {ImageFilePath: tempdir + "/" + glyphImg[5]},
|
|
||||||
{ImageFilePath: tempdir + "/" + glyphImg[6]}, {ImageFilePath: tempdir + "/" + glyphImg[7]},
|
|
||||||
{ImageFilePath: tempdir + "/" + glyphImg[8]}, {ImageFilePath: tempdir + "/" + glyphImg[9]},
|
|
||||||
{ImageFilePath: tempdir + "/" + glyphImg[10]}, {ImageFilePath: tempdir + "/" + glyphImg[11]},
|
|
||||||
}
|
|
||||||
|
|
||||||
if vopt == 1 { // set vertical rendering
|
|
||||||
vert, horz = 1, 12
|
|
||||||
} else { // set horizontal rendering (default)
|
|
||||||
vert, horz = 12, 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// create new image from grids
|
|
||||||
rgba, err := gim.New(grids, vert, horz).Merge()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resize banner 768x64
|
|
||||||
nuimg := resize.Resize(768, 64, rgba, resize.Lanczos3)
|
|
||||||
|
|
||||||
// save the output to png
|
|
||||||
fmt.Printf("Saving %s to %s\n", portalhex, savename)
|
|
||||||
file, err := os.Create(savename)
|
|
||||||
err = png.Encode(file, nuimg)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
7
go.mod
7
go.mod
@@ -1,8 +1,5 @@
|
|||||||
module gitlab.com/bradley.richins/nmslib
|
module gitlab.com/Raum0x2A/nmslib
|
||||||
|
|
||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require github.com/ozankasikci/go-image-merge v0.2.2
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
|
||||||
github.com/ozankasikci/go-image-merge v0.2.2
|
|
||||||
)
|
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -1,4 +1,2 @@
|
|||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
|
||||||
github.com/ozankasikci/go-image-merge v0.2.2 h1:K370BLLTIsamwjAeViiPntf7GiG3h9pXzDmxXCbN8/0=
|
github.com/ozankasikci/go-image-merge v0.2.2 h1:K370BLLTIsamwjAeViiPntf7GiG3h9pXzDmxXCbN8/0=
|
||||||
github.com/ozankasikci/go-image-merge v0.2.2/go.mod h1:NQ2aN0b21buFx3p+5x4dZrKuPSLh2uBukK7F30BrYTo=
|
github.com/ozankasikci/go-image-merge v0.2.2/go.mod h1:NQ2aN0b21buFx3p+5x4dZrKuPSLh2uBukK7F30BrYTo=
|
||||||
|
|||||||
32
lang.go
32
lang.go
@@ -12,7 +12,7 @@ import (
|
|||||||
Translate words
|
Translate words
|
||||||
*/
|
*/
|
||||||
type Translate struct {
|
type Translate struct {
|
||||||
word string
|
Word string
|
||||||
}
|
}
|
||||||
|
|
||||||
// trans - set up structure of a word iteration
|
// trans - set up structure of a word iteration
|
||||||
@@ -121,11 +121,11 @@ func toEng(t Translate, csvlines [][]string) string {
|
|||||||
acpword: strings.ToLower(line[3]),
|
acpword: strings.ToLower(line[3]),
|
||||||
}
|
}
|
||||||
// check translate struct for value
|
// check translate struct for value
|
||||||
if strings.ToLower(t.word) == lang.word {
|
if strings.ToLower(t.Word) == lang.word {
|
||||||
returnstring = lang.english
|
returnstring = lang.english
|
||||||
} else if strings.ToLower(t.word) == lang.capword {
|
} else if strings.ToLower(t.Word) == lang.capword {
|
||||||
returnstring = strings.Title(strings.ToLower(lang.english))
|
returnstring = strings.Title(strings.ToLower(lang.english))
|
||||||
} else if strings.ToLower(t.word) == lang.acpword {
|
} else if strings.ToLower(t.Word) == lang.acpword {
|
||||||
returnstring = strings.ToUpper(lang.english)
|
returnstring = strings.ToUpper(lang.english)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,17 +141,17 @@ func toNMS(t Translate, csvlines [][]string) string {
|
|||||||
capword: line[2],
|
capword: line[2],
|
||||||
acpword: line[3],
|
acpword: line[3],
|
||||||
}
|
}
|
||||||
if t.word == lang.english {
|
if t.Word == lang.english {
|
||||||
if lang.word != "" {
|
if lang.word != "" {
|
||||||
returnstring = lang.word
|
returnstring = lang.word
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if t.word == strings.Title(strings.ToLower(lang.english)) {
|
if t.Word == strings.Title(strings.ToLower(lang.english)) {
|
||||||
if lang.capword != "" {
|
if lang.capword != "" {
|
||||||
returnstring = strings.Title(strings.ToLower(lang.capword))
|
returnstring = strings.Title(strings.ToLower(lang.capword))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if t.word == strings.ToUpper(lang.english) {
|
if t.Word == strings.ToUpper(lang.english) {
|
||||||
if lang.acpword != "" {
|
if lang.acpword != "" {
|
||||||
returnstring = strings.ToUpper(lang.acpword)
|
returnstring = strings.ToUpper(lang.acpword)
|
||||||
}
|
}
|
||||||
@@ -160,6 +160,21 @@ func toNMS(t Translate, csvlines [][]string) string {
|
|||||||
return returnstring
|
return returnstring
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
func openCSV(lagcsv string) [][]string {
|
||||||
|
csvFile, err := os.Open("./assets/lang/" + lagcsv)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
defer csvFile.Close() // close language file when finished
|
||||||
|
|
||||||
|
// read csv file from memory
|
||||||
|
csvlines, err := csv.NewReader(csvFile).ReadAll()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
return csvlines
|
||||||
|
*/
|
||||||
func openCSV(lagcsv string) [][]string {
|
func openCSV(lagcsv string) [][]string {
|
||||||
// create temp dir
|
// create temp dir
|
||||||
tempdir, err := ioutil.TempDir("", "nmslib-")
|
tempdir, err := ioutil.TempDir("", "nmslib-")
|
||||||
@@ -169,7 +184,7 @@ func openCSV(lagcsv string) [][]string {
|
|||||||
defer os.RemoveAll(tempdir) // Clean up temp files
|
defer os.RemoveAll(tempdir) // Clean up temp files
|
||||||
|
|
||||||
// extract language file from resources.go
|
// extract language file from resources.go
|
||||||
data, err := Asset(lagcsv)
|
data, err := Asset("assets/lang/" + lagcsv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -188,4 +203,5 @@ func openCSV(lagcsv string) [][]string {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
return csvlines
|
return csvlines
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,17 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestRndPortal(t *testing.T) {
|
||||||
|
fmt.Printf("\nRandom Portal Code: ")
|
||||||
|
fmt.Println(RndPortal())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCreateBanner(t *testing.T) {
|
||||||
|
fmt.Printf("\nTesting CreateBanner: ")
|
||||||
|
CreateBanner(RndPortal(), "/tmp/Test.png", 11)
|
||||||
|
fmt.Printf("Random Portal address rendered as `/tmp/Test.png`\n\n")
|
||||||
|
}
|
||||||
|
|
||||||
func TestPortal2Galactic(t *testing.T) {
|
func TestPortal2Galactic(t *testing.T) {
|
||||||
want, err := P2gc("006afa556c30")
|
want, err := P2gc("006afa556c30")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -49,11 +60,6 @@ func TestGalactic2portal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateBanner(t *testing.T) {
|
|
||||||
fmt.Printf("\nTesting CreateBanner: ")
|
|
||||||
CreateBanner("006afa556c30", "/tmp/Test.png", 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTranslate(t *testing.T) {
|
func TestTranslate(t *testing.T) {
|
||||||
want := Translate{"Paka"}
|
want := Translate{"Paka"}
|
||||||
if want.Atl2Eng() != "Awake" {
|
if want.Atl2Eng() != "Awake" {
|
||||||
|
|||||||
BIN
ranportal_scaled.png
Normal file
BIN
ranportal_scaled.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
674
resources.go
674
resources.go
File diff suppressed because one or more lines are too long
41
rpcg.go
Normal file
41
rpcg.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package nmslib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
[P][SSS][YY][ZZZ][XXX] – (P = Planet Index / S = Star System Index / Y = Height / Z = Width / X = Length)
|
||||||
|
|
||||||
|
`Solar System Index
|
||||||
|
A Solar System Index is assigned to each star system in a region. It always begins at SolarSystemIndex=001
|
||||||
|
and counts up by one for every star system. The number of star systems in a region is variable so the
|
||||||
|
maximum value of the Solar System Index is also variable, though the two correspond directly. To date there
|
||||||
|
is no discovered value that is higher than SolarSystemIndex=243 (Mamundi-Kate in the Baadossm Anomaly of
|
||||||
|
Euclid galaxy), meaning that 579 is the maximum number of star systems yet discovered in a region. Based
|
||||||
|
on the evidence that every region has a SolarSystemIndex=079 and SolarSystemIndex=07A (with the former
|
||||||
|
always having a Black Hole and the latter always having an Atlas Station), it is known that every region has
|
||||||
|
at least 122 star systems. SolarSystemIndex=000 always leads to the region's first system, just like
|
||||||
|
PlanetIndex=0 always leads to the first portal of a system due to the error proximity mechanic.`
|
||||||
|
Source https://nomanssky.fandom.com/wiki/Portal_address#Solar_System_Index
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
func RndPortal() (final string) {
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
min := 0x1
|
||||||
|
ymax := 0xFF
|
||||||
|
xzmax := 0xFFF
|
||||||
|
ssimax := 0x242 // set this low to lower chances of an invalid address
|
||||||
|
|
||||||
|
x := rand.Intn(xzmax-min+1) + min
|
||||||
|
z := rand.Intn(xzmax-min+1) + min
|
||||||
|
y := rand.Intn(ymax-min+1) + min
|
||||||
|
ssi := rand.Intn(ssimax-min+1) + min
|
||||||
|
|
||||||
|
final = fmt.Sprintf("%00X%03X%02X%03X%03X", 1, ssi, y, z, x)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user