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.