Skip to content

Commit

Permalink
Initial zs to groovy attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
juraj-hrivnak committed Oct 10, 2023
1 parent 33b5018 commit 54f7b49
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
40 changes: 40 additions & 0 deletions groovy/postInit/zsToGroovy/_zsTo.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//NO_RUN

import groovy.io.FileType

import java.nio.file.Files

def workingDir = new File('groovy/postInit/zsToGroovy')

if (!workingDir.exists()) {
workingDir.mkdir()
}

workingDir.eachFileRecurse (FileType.FILES) { file ->
if (file.name.endsWith('.zs')) {
new File('groovy/postInit/zsToGroovy/' + file.name.replace('.zs', '.groovy')).with {
it.delete()
it.withWriter { w ->
file.eachLine { line ->
if (line.startsWith('//')) {
w << line
} else {
w << line
.replace('#modloaded', '//MOD_LOADED')
.replace(';', '')
.replace('"', '\'')
.replace('<ore:', 'ore(\'')
.replace('<', 'item(\'')
.replace('>', '\')')
.replace('val', 'def')
.replace('recipes.removeByRecipeName', 'crafting.remove')
.replace('recipes.remove', 'crafting.removeByOutput')
.replace('recipes', 'crafting')
}

w << System.getProperty("line.separator")
}
}
}
}
}
3 changes: 2 additions & 1 deletion groovy/runConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"postInit/woodworking",
"postInit/vanilla",
"postInit/",
"postInit/generated"
"postInit/generated",
"postInit/zsToGroovy"
]
}
}

0 comments on commit 54f7b49

Please sign in to comment.