https://github.com/foso/scrako
Kotlin libary/DSL for text based generation of Scratch (lang) projects
https://github.com/foso/scrako
scratch scratch-lang turbowarp
Last synced: 6 months ago
JSON representation
Kotlin libary/DSL for text based generation of Scratch (lang) projects
- Host: GitHub
- URL: https://github.com/foso/scrako
- Owner: Foso
- Created: 2024-10-20T20:28:27.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-03-15T10:17:27.000Z (7 months ago)
- Last Synced: 2025-03-15T11:23:40.463Z (7 months ago)
- Topics: scratch, scratch-lang, turbowarp
- Language: Kotlin
- Homepage:
- Size: 330 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Scrako
Kotlin library/DSL for text based generation of Scratch (lang) projects
## Show some :heart: and star the repo to support the project
[](https://github.com/Foso/Scrako) [](https://github.com/Foso/Scrako/fork)
## Scrako Packages
| Project | Version |
|-------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| Scrako Core | [](https://central.sonatype.com/artifact/de.jensklingenberg.scrako/scrako-core) |
| Scratch3 | [](https://central.sonatype.com/artifact/de.jensklingenberg.scrako/scratch3) |# Hello World
You can also find a example project in the examples folder
![]()
```kotlin
projectBuilder {
spriteBuilder("foo") {
scriptBuilder {
whenFlagClicked()
say("Hello!")
}
}
}
```# All sprite variables
```kotlin
projectBuilder {
val myVar = getGlobalVariable("myVar")
...
}
```You can create a global variable in the scope of the projectBuilder
# Single sprite variables
```kotlin
scriptBuilder {
val myVar = createVariable("myVar")
...
}
```# Broadcasts
```kotlin
projectBuilder {
val paint = createBroadcast("paint")
...
}
```# All sprite lists
```kotlin
projectBuilder {
val myVar = createGlobalList("myVar")
...
}
```You can create a global variable in the scope of the projectBuilder
# Single sprite lists
```kotlin
scriptBuilder {
val myVar = createList("myVar")
...
}
```# Custom blocks
## Define custom block
```kotlin
define(
name = "foo",
withoutRefresh = true,
arguments = listOf(Argument("bar", ArgumentType.NUMBER_OR_TEXT), Argument("baz", ArgumentType.BOOLEAN))
) {
// your code here
}
```## Get arguments
![]()
```kotlin
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
```kotlin
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.```kotlin
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