Update readme

This commit is contained in:
Maxwell Jeffress 2024-12-16 13:42:46 +11:00
parent bb31f570c2
commit 58dfb8c923

View File

@ -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. 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 {
<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 ### 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. 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.