chookspeak/README.md
Maxwell Jeffress d09f419c0f Add README
2024-12-13 11:30:47 +11:00

2.4 KiB

Chookspeak

A language for coding Chookchat Eggs.

What is Chookspeak?

Chookspeak is a language designed for the sole purpose of not forcing people to write a lot of confusing Javascript to build Chookchat Eggs. It's in very early development, and only has basic features. Chookspeak's syntax is a weird mix of Kotlin curly braced syntax and Javascript event handling. It's designed to not be hard to pick up and learn, especially if you have prior experience with those languages.

Let's start coding!

To start, make a new file ending in .chsp. Start on the first line by defining your egg name.

egg notepad

This is a requirement of every Chookspeak program. The compiler WILL complain if you forget to do so. Next, define your initial startup, which is executed when your egg is opened. Let's log something to the console with the log keyword.

egg notepad

init {
    log "Hello World!"
}

Notice how no brackets are needed, similar to Python 2 syntax. You do need to have a string with double quotes, similar to how Kotlin works. Each instruction takes a line. No semicolons, for now.

Next, define what your egg will look like, with a html section in the init section.

egg notepad

init {
    log "Hello World!"
    html {
        <p>This is an egg.</p>
    }
}

You can write whatever HTML you want inside there, including CSS styles. Keep in mind your space constraints with Chookchat when styling things. Now, send a message to the server (which will be in relation to your egg)

egg notepad

init {
    log "Hello World!"
    html {
        <p>This is an egg.</p>
    }
    sendMessage "Hello from my egg!"
}

Note: Everything after this line (for now) is either experimental or in development.

If there's any Javascript you want to run on startup, add a JS section in your init.

egg notepad

init {
    log "Hello World!"
    html {
        <p>This is an egg.</p>
    }
    sendMessage "Hello from my egg!"
    js {
        alert("This is actually javascript inside an egg");
    }
}

Variables and values/constants can be defined with val and var, just like in Kotlin.

egg notepad

init {
    log "Hello World!"
    html {
        <p>This is an egg.</p>
    }
    sendMessage "Hello from my egg!"
    js {
        alert("This is actually javascript inside an egg");
    }
    val myValue = "This is a value"
    var myVariable = "This is a variable"
}