Add JS sections
This commit is contained in:
parent
d09f419c0f
commit
09787d7113
11
README.md
11
README.md
|
@ -53,9 +53,10 @@ init {
|
|||
}
|
||||
```
|
||||
|
||||
**Note: Everything after this line (for now) is either experimental or in development.**
|
||||
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
|
||||
|
||||
|
@ -71,6 +72,8 @@ 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.
|
||||
|
||||
```
|
||||
|
@ -89,3 +92,9 @@ init {
|
|||
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.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// comment lmao
|
||||
/* a confusing comment */
|
||||
egg notepad
|
||||
init {
|
||||
sendMessage "Hello there!"
|
||||
|
@ -7,6 +6,9 @@ init {
|
|||
<textarea id="dingus">
|
||||
}
|
||||
log "egg initialised"
|
||||
js {
|
||||
alert("this is an alert! i repeat - this is an alert!");
|
||||
}
|
||||
}
|
||||
|
||||
onRecieving egg * * {
|
||||
|
|
|
@ -108,6 +108,9 @@ fun main(args: Array<String>) {
|
|||
if (status == listOf("init", "html") && lineArgs[0] != "html") {
|
||||
outputHTML.appendText("${lineArgs.joinToString(" ")}\n")
|
||||
}
|
||||
if (status == listOf("init", "js") && lineArgs[0] != "js") {
|
||||
outputIndexJS.appendText("${lineArgs.joinToString(" ")}\n")
|
||||
}
|
||||
lineCounter ++
|
||||
} else if (commenting == 1) {
|
||||
commenting = 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user