diff --git a/README.md b/README.md new file mode 100644 index 0000000..7b06571 --- /dev/null +++ b/README.md @@ -0,0 +1,91 @@ +# 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 { +
This is an egg.
+ } +} +``` + +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 { +This is an egg.
+ } + 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 { +This is an egg.
+ } + 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 { +This is an egg.
+ } + 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" +} +``` diff --git a/examples/main.chsp b/examples/main.chsp index 68d47c9..d12be6c 100644 --- a/examples/main.chsp +++ b/examples/main.chsp @@ -9,7 +9,7 @@ init { log "egg initialised" } -onRecieving egg, *, * { +onRecieving egg * * { messagehtml {