4.0 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!"
}
Add comments to your code with // comment here
, or /* comment here */
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"
}
You can update variables without redeclaring them (make sure to use the var
keyword instead of val
)
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"
myVariable == "I just changed the variable without reinitialising it."
}
Note: Everything after this line (for now) is either experimental or in development.
Use if
statements to run certain code if conditions are met.
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"
myVariable == "I just changed the variable without reinitialising it."
var anotherVariable = 0
if (anotherVariable == 0) {
log "I'm going to make this variable not zero"
anotherVariable ++
}
log anotherVariable
}
How to use the language
You can transpile Chookspeak to Javascript and HTML by using the program in the repository. Compile it with gradle installDist
, then run ./build/install/chookspeak/bin/chookspeak
(add .bat if you're a crazy Windows user). You'll notice it complains about not having a file. Add the path as your argument. eg ./build/install/chookspeak/bin/chookspeak notepad.chsp
. Your program should be compiled to HTML and Javascript in valid egg format, which can be added to your Chookchat instance.