Kotlin library/DSL for text based generation of Scratch (lang) projects
Project | Version |
---|---|
Scrako Core | |
Scratch3 |
You can also find a example project in the examples folder
projectBuilder {
spriteBuilder("foo") {
scriptBuilder {
whenFlagClicked()
say("Hello!")
}
}
}
projectBuilder {
val myVar = getGlobalVariable("myVar")
...
}
You can create a global variable in the scope of the projectBuilder
scriptBuilder {
val myVar = createVariable("myVar")
...
}
projectBuilder {
val paint = createBroadcast("paint")
...
}
projectBuilder {
val myVar = createGlobalList("myVar")
...
}
You can create a global variable in the scope of the projectBuilder
scriptBuilder {
val myVar = createList("myVar")
...
}
define(
name = "foo",
withoutRefresh = true,
arguments = listOf(Argument("bar", ArgumentType.NUMBER_OR_TEXT), Argument("baz", ArgumentType.BOOLEAN))
) {
// your code here
}
define(
"foo",
withoutRefresh = true,
arguments = listOf(Argument("bar", ArgumentType.NUMBER_OR_TEXT), Argument("baz", ArgumentType.BOOLEAN))
) {
val (bar, baz) = getArgs()
say(bar)
say(baz)
}
Use destructuring to get the arguments from getArgs()
call("foo", listOf(StringBlock("Hello"), StringBlock("World") eq "true"))
Scrako is only building the project file. I use TurboWarp Desktop to run the project. https://desktop.turbowarp.org/ This my setup for Mac but there should be similar commands for Windows and Linux.
private fun startTurboWarp(filePath: String) {
val processBuilder2 = ProcessBuilder("open", filePath)
processBuilder2.inheritIO()
val process2 = processBuilder2.start()
process2.waitFor()
}
private fun killTurboWarp() {
val processBuilder = ProcessBuilder("pkill", "-9", "TurboWarp")
processBuilder.inheritIO()
val process = processBuilder.start()
process.waitFor()
}
- scratch3 - Contains all blocks from Scratch 3.0 + pen extensions
- turbo-warp - Contains scratch3 + some turbo-warp blocks