README.md 2.8 KB

Transplier

Can be found here: https://github.com/chopeks/kotlin-to-qsp-transpiler

If there are bugs or so in transpiler, let me know.

Mod writing

  1. Intellij IDEA is recommended (can be community edition)
  2. check Main.kt and change directories
  3. put mod files in src/main/kotlin/qsrc
    • files can be placed in sub directories
    • you can use 'empty_file_you_can_copy.kts' as template
    • you can put qsrc files too, they'll be copied as is

Compiling this project will result in generated .qsp file!

NOTE: mod files have to be .kts (.kt won't transpile)

API

There are a few apis already covered in com.chopeks.glife package, for example:

  • all Girl Life locations
  • most (some may be missing) of Girl Life variables
  • enums for:
    • arousal
    • pain
    • location type
    • fetishes
    • more to come (probably ;))

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

NOTE: no comments allowed inside of function body, it's ok to have comment outside of function body

Other API tricks

GS, GT and GLLoc:

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

Separating code in one line

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()
KillVar

you can use variable directly:

killVar(temp) // which will translate to killvar 'temp'
Types

There are 2 types:

  • QspType - which is kotlin Any on steroids (more operators, array access etc)
  • QspCodeTemplate - which is used with conjunction with dynamic() (also allows kotlin anonymous lambda)
Strings

Strings are normal, with " as \" escape, while ' is '. No doubles.