https://github.com/alicerunsonfedora/kspeak

A Kotlin DSL for writing visual novel-like and cutscene scripts

https://github.com/alicerunsonfedora/kspeak

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.4%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

A Kotlin DSL for writing visual novel-like and cutscene scripts

Basic Info
  • Host: GitHub
  • Owner: alicerunsonfedora
  • License: mpl-2.0
  • Language: Kotlin
  • Default Branch: root
  • Size: 93.8 KB
Statistics
  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 2
Created almost 5 years ago · Last pushed almost 5 years ago
Metadata Files
Readme License

README.md

kspeak

A Kotlin DSL for writing visual novel-like and cutscene scripts for games

:warning: This library is experimental and not complete. Use at your own risk.

Getting started

Add the following information to your build.gradle.kts file:

```kotlin // MERGE THIS WITH YOUR REPOSITORIES ENTRY repositories { maven { name = "GitHubPackages" url = uri("https://maven.pkg.github.com/alicerunsonfedora/kspeak") credentials { username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME") password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN") } } }

// MERGE THIS WITH YOUR DEPENDENCIES ENTRY dependencies { implementation("kspeak:lib:1.0-SNAPSHOT") implementation(kotlin("script-runtime")) } ```

Create a personal access token with access to packages. In your gradle.properties file, add the following:

gpr.user=yourGitHubUserName gpr.key=yourGitHubToken

You should now be able to reload Gradle and install the library.

Usage

It is recommended to use kspeak in a Kotlin script to auto-generate files when running them.

An example script looks like:

```kotlin import kspeak.*

buildScene { version(1) outputToFile("helloWorld.json")

parts {
    dialogue {
        narrate("Hello, world!")
    }
}

}

```

Creating a scene

The buildScene method allows you to dynamically create a scene that can be exported to JSON.

First, define a version and the output path. The version should remain 1 unless using a later schema version:

```kotlin import kspeak.*

buildScene { version(1) outputToFile("path/to/your/json/file/here.json") } ```

If you are using buildScene in your code and want to use the JSON string directly, you can omit outputToFile.

Defining parts

The majority of the scripting occurs in parts, which lets you define the list of parts in the script.

There are two kinds of parts currently:

  • dialogue, which lets you write a block of dialogue for characters and narrators.
  • branch, which lets you write decision branches with options that contain dialogue.

Characters

Characters are defined with the Character class and are used to make up dialogue and decision branches. These should be instantiated before dialogue and branch parts:

parts { val player = Character("Player") }

The Character class takes in a single parameter, name. This name can be referenced by calling toString() on the class or in string interpolation:

kotlin val player = Character("Player") println("The character's name is $player.")

Dialogue

To write a dialogue block, call dialogue in the parts method:

```kotlin parts { dialogue {

}

}

```

There are three different ways of writing dialogue:

  • narrate, which takes in a single string for narration
  • line, which takes in the result of Character.speak
  • monologue, which takes in commands of say

To write a line for narration, call narrate, which automatically creates a narrator character:

kotlin dialogue { narrate("I gently open the door.") }

To have a character speak a line, call on Character.speak in conjunction with line:

kotlin val player = Character("Player") dialogue { line(player.speak("Hello, world!")) }

To specify that a certain image name be shown, add the imageName parameter:

kotlin val player = Character("Player") dialogue { line(player.speak("How are you all?", imageName = "wave")) }

To write a monologue or group lines together, call monologue. Lines can be instantiated by using the say operator:

```kotlin val player = Character("Player") val katorin = Character("Katorin")

dialogue { monologue { this say player.speak("Hey, $katorin...") this say player.speak("Did the package compile?") } } ```

Decision Branches

Create decision branches with the branch method. Each option will contain a prompt and dialogue (see: Dialogue):

kotlin branch { option("Go to the store.") { narrate("I decide to go to the store.") } option("Go to the cafe.") { narrate("Maybe I should get coffee first...") } }

To have a player cycle through all options before reaching the next block, add the parameter waitForAll:

kotlin branch(waitForAll = true) { option("Rock") { } option("Scissors") { } option("Paper") { } }

Options

Define options with the option method, which takes in a name that appears on screen and a block of dialogue:

kotlin option("Call Luma.") { narrate("Calling her wouldn't be a bad idea.") }

JSON Format

When serialized and exported, the JSON file will contain similarly-constructed data of the scene script:

As an example:

json { "version": "1", "parts": [ { "kind": "DIALOGUE", "dialogue": [ {"narrator": "Hello, world!"}, { "Player": "Hey, all.", "image": "feetUpOnTable" } ] }, { "kind": "BRANCH", "branch": [ { "name": "Wave.", "dialogue": [ {"narrator": "I wave to everyone."} ] } ], "options": { "waitForAll": false } } ] }

The format should be readable and allow developers to write dialogue UI or other systems that can render the appropriate data.

Owner

  • Name: Marquis Kurt
  • Login: alicerunsonfedora
  • Kind: user
  • Location: Bear, DE

[mar.kɪs kɚrt] He/him. iOS app and game developer.

GitHub Events

Total
Last Year

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 13
  • Total Committers: 1
  • Avg Commits per committer: 13.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Marquis Kurt s****e@m****t 13
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Dependencies

lib/build.gradle.kts maven
  • org.apache.commons:commons-math3 3.6.1 api
  • com.google.guava:guava 30.1.1-jre implementation
  • org.jetbrains.kotlin:kotlin-stdlib-jdk8 * implementation
  • org.jetbrains.kotlinx:kotlinx-serialization-json 1.2.2 implementation
  • org.jetbrains.kotlin:kotlin-test * testImplementation
  • org.jetbrains.kotlin:kotlin-test-junit * testImplementation