From 58dfb8c92372f8924c0c6c6a6384b44c4f7c7eb9 Mon Sep 17 00:00:00 2001 From: Maxwell Jeffress Date: Mon, 16 Dec 2024 13:42:46 +1100 Subject: [PATCH] Update readme --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd524e6..efcdafd 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,6 @@ init { } ``` -**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. ``` @@ -93,6 +91,54 @@ init { } ``` +You can update variables without redeclaring them (make sure to use the `var` keyword instead of `val`) + +``` +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" + 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 { +

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" + 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.