Can be found here: https://github.com/chopeks/kotlin-to-qsp-transpiler
If there are bugs or so in transpiler, let me know.
Compiling this project will result in generated .qsp file!
There are a few apis already covered in com.chopeks.glife package, for example:
There are also some kotlin extensions in com.chopeks.glife.extensions. These fragments of code are copied as is (with parameters replaced) during transpiling. For example
fun GLExtensions.image(__image: String) {
"<center><img ${`$set_imgh`} src=__image/></center>"
}
// and calling it like this:
ext.image("mod/image/whatever.jpg")
will be translated to:
'<center><img <<$set_imgh>> src="mod/image/whatever.jpg"/></center>`
in qsrc file.
You can also define your own in mod.extensions.ModExtensions.kt
Instead of going like:
gs 'bed2', 'start'
You can do that typesafe way like this:
gs(GLLoc.bed2.start)
which will be transpiled to one above. One note here: when using with GT,GS,XGT - it will transpile to whole path, but when using it in if statement, or assignment, it will transpile to last value. For example:
// this will translate to gs 'bed2', 'start'
gs(GLLoc.bed2.start)
// this will translate to if $args[0] = 'start':
if(`$args`[0] == GLLoc.bed2.start)
// but this one will translate to if $args[0] = 'bed2':
if(`$args`[0] == GLLoc.bed2)
You can also define your own mod structure in ModLocation.kt
Qsp uses &
, kotlin uses ;
, so:
// in qsp: *clr& cla
clr(); cla()
Note that kotlin if can only have 1 statement without brackets, so:
if(n == 0) clr(); cla()
is same as
if(n == 0) {
clr()
}
cla()
you can use variable directly:
killVar(temp) // which will translate to killvar 'temp'
There are 2 types:
Strings are normal, with " as \" escape, while ' is '. No doubles.