# 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!" } ``` 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 {This is an egg.
} sendMessage "Hello from my egg!" js { alert("This is actually javascript inside an egg"); } } ``` **Note: Everything after this line (for now) is either experimental or in development.** 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" } ``` ### 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. When running the transpiler, don't be worried if debug messages come up. For now, there's no way to error it other than having your egg declaration not at the start of your code.