Skip to content
/ Scrako Public

Kotlin libary/DSL for text based generation of Scratch (lang) projects

Notifications You must be signed in to change notification settings

Foso/Scrako

Repository files navigation

Scrako

Kotlin library/DSL for text based generation of Scratch (lang) projects

Show some ❤️ and star the repo to support the project

GitHub stars GitHub forks

Scrako Packages

Project Version
Scrako Core Maven Central
Scratch3 Maven Central

Hello World

You can also find a example project in the examples folder

projectBuilder {
    spriteBuilder("foo") {
        scriptBuilder {
            whenFlagClicked()
            say("Hello!")
        }
    }
}

All sprite variables

projectBuilder {
    val myVar = getGlobalVariable("myVar")
    ...
}

You can create a global variable in the scope of the projectBuilder

Single sprite variables

scriptBuilder {
    val myVar = createVariable("myVar")
    ...
}

Broadcasts

projectBuilder {
    val paint = createBroadcast("paint")
    ...
}

All sprite lists

projectBuilder {
    val myVar = createGlobalList("myVar")
    ...
}

You can create a global variable in the scope of the projectBuilder

Single sprite lists

scriptBuilder {
    val myVar = createList("myVar")
    ...
}

Custom blocks

Define custom block

define(
    name = "foo",
    withoutRefresh = true,
    arguments = listOf(Argument("bar", ArgumentType.NUMBER_OR_TEXT), Argument("baz", ArgumentType.BOOLEAN))
) {
// your code here
}

Get arguments

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 custom block

call("foo", listOf(StringBlock("Hello"), StringBlock("World") eq "true"))

Development tips

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

Dependencies

  • scratch3 - Contains all blocks from Scratch 3.0 + pen extensions
  • turbo-warp - Contains scratch3 + some turbo-warp blocks

About

Kotlin libary/DSL for text based generation of Scratch (lang) projects

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages