Skip to content

Commit

Permalink
map preview generator
Browse files Browse the repository at this point in the history
  • Loading branch information
rajderks committed Jul 31, 2020
1 parent d14cd3b commit 765cf20
Show file tree
Hide file tree
Showing 13 changed files with 985 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ yarn-debug.log*
yarn-error.log*
src/util/__tests__/LOUD/**/*
quokka
quokka-scratch.ts
quokka-scratch.ts
maps
4 changes: 4 additions & 0 deletions ambient.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module 'binary';
declare module 'parse-dds';
declare module 'buffer-to-arraybuffer';
declare module 'gl-dds';
76 changes: 76 additions & 0 deletions main copy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package main

import (
"io/ioutil"
"os"
"regexp"
)

type Replace struct {
Regexp string
Replacer string
}
var replaces = []Replace{
{
Regexp: "[ \\t]+",
Replacer: "",
},
{
Regexp: "--.+\n",
Replacer: "",
},
{
Regexp: "([\\w]+)=",
Replacer: "'$1'=",
},
{
Regexp: `=.*['\(\}\{]+([-\d\w\/,.]+)['\)\}\{]+`,
Replacer: "='$1'",
},
{
Regexp: "GROUP{",
Replacer: "{",
},
{
Regexp: ",\r?\n\\}",
Replacer: "\n}",
},
{
Regexp: "'",
Replacer: `"`,
},
{
Regexp: "=",
Replacer: ":",
},
{
Regexp: `^"Scenario":`,
Replacer: "var Scenario=",
},
{
Regexp: `\[|\]`,
Replacer: "",
},
}

func main() {
f, err := os.Open("test.lua")
if err != nil {
panic(err)
}
d, err := ioutil.ReadAll(f)
if err != nil {
panic(err)
}
for _, replace := range replaces {
expr, err := regexp.Compile(replace.Regexp)
if err != nil {
panic(err)
}
d = expr.ReplaceAll(d, []byte(replace.Replacer))
}

f.Close()
f, err = os.Create("test.js")
f.Write(d)
}
2 changes: 1 addition & 1 deletion nodemon.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"watch": "src/**/*.ts",
"execMap": {
"ts": "ts-node"
"ts": "ts-node --files"
}
}
Loading

0 comments on commit 765cf20

Please sign in to comment.