Skip to content

Commit

Permalink
corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
x87 committed Feb 6, 2024
1 parent 3f48c3d commit eec01b0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
9 changes: 4 additions & 5 deletions content/cleo-directive.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The last piece to learn before writing a CLEO script is to understand how to compile it and see in the game.

Sanny Builder makes it trivial. You need to go to `File` -> `New CLEO script...`.
Sanny Builder makes it trivial. You need to go to `File` -> `New CLEO script...`.

<img src="/img/comp-2.png" alt="New CLEO script menu" width="400"/>

Expand All @@ -15,11 +15,10 @@ terminate_this_custom_script

Here you can see two commands: `nop` and `terminate_this_custom_script`, one that we saw already. `nop` does nothing, it is just a placeholder, but it comes in handy when using loops. We will discuss them in the next chapter. For now you can simply ignore or delete this line.

The key part here is the first line: `{$CLEO .cs}`. Lines enclosed in `{$...}` are _directives_. They are special commands that alter Sanny Builder's behavior during [compilation](./sanny-builder).
The key part here is the first line: `{$CLEO .cs}`. Lines enclosed in `{$...}` are _directives_. They are special commands that alter Sanny Builder's behavior during [compilation](/sanny-builder).

`$CLEO` directive tells Sanny Builder to compile the script as a separate file with `.cs` extension. All you need to do after it is to copy the compiled file into the game folder. Sanny Builder will do it for you if you press `F7` or go to `Run` -> `Compile + Copy`.
`$CLEO` directive tells Sanny Builder to compile the script as a separate file with `.cs` extension. All you need to do is to copy the compiled `.cs` file into the game folder. Sanny Builder can do it for you if you press `F7` or go to `Run` -> `Compile + Copy`.

<img src="/img/comp-3.png" alt="Compile+Copy menu" width="400"/>


Without `{$CLEO}` this script will be compiled into a `main.scm` file.
Without `{$CLEO}` this script will be compiled into a `main.scm` file.
8 changes: 5 additions & 3 deletions content/conditions.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Often you want to run some code only if a certain condition is met. For example, you might want to show a message if a certain button pressed.
Often times you want to run some code only if a certain condition is met. For example, you might want to show a message if a certain button pressed.

To do this, you can use the `if` statement. It has the following syntax:

Expand All @@ -9,7 +9,9 @@ then
end
```

A `<condition>` is a conditional instruction. It is written just like any other command, but after execution it changes the status of the current `if` statement to `true` or `false`. If the status is `true`, the code inside the `then..end` block is executed. If the status is `false`, the code is skipped:
where `<condition>` is a single conditional instruction. It is written just like any other command, but after execution it changes the status of the current `if` statement to `true` or `false`.

If the status is `true`, the code inside the `then..end` block is executed. If the status is `false`, the code inside the `then..end` block is skipped:

```sb
if is_key_pressed 113 // F2
Expand All @@ -18,4 +20,4 @@ then
end
```

This script will show a help message if the F2 key is pressed. If the F2 key is not pressed, the `then..end` block will be skipped, and `print_help` will not be executed.
This script will show a help message only if the `F2` key is pressed.
2 changes: 1 addition & 1 deletion content/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ print_help 'GXT_KEY'
load_sprite 1 "DOWN"
```

For the purpose of this tutorial, we will use the term _literal_ to refer to number and string constants hardcoded in the source code. `12`, `30`, `0.5` are number literals. `GXT_KEY`, `DOWN` are string literals.
`GXT_KEY`, `DOWN` are string literals.
6 changes: 4 additions & 2 deletions content/variables.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
Opposite to number and string literals are variables. A _variable_ is a named storage for a value. A variable can store a number or a string. Its value can change over time. This operation is called assignment. A variable can be assigned a literal or another variable. For example:
Variables are opposite to number and string literals. A _variable_ is a named storage for a value. A variable can store a number or a string. Its value can change over time through the operation called assignment. A variable can be assigned a literal or a value of another variable. For example:

```sb
int hour = 12
int minute = 30
hour = 13
minute = 0
hour = minute
```

The first two lines declare two variables, `hour` and `minute`, and assign them values `12` and `30` respectively. The next two lines change the values of these variables to `13` and `0`.
The first two lines declare two variables, `hour` and `minute`, and assign them values `12` and `30` respectively. The next two lines change the values of these variables to `13` and `0`. Finally, the last line assigns the value of `minute` to `hour`. After this line, both `hour` and `minute` will have the value of `0`.

Variables that hold integer values are declared with the `int` keyword. You can then use them in commands that expect an integer number. For example:

Expand Down
15 changes: 12 additions & 3 deletions eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const pluginNavigation = require("@11ty/eleventy-navigation");
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
const pascal = require("prismjs/components/prism-pascal");


const pluginImages = require("./eleventy.config.images.js");
const toc = require("./_data/toc.json");

Expand Down Expand Up @@ -46,10 +45,20 @@ module.exports = function (eleventyConfig) {
lookbehind: true,
},
],
'comment': {
comment: {
pattern: /\/\*[\s\S]*?\*\/|\{[\s\S]*?\}|\/\/.*/,
greedy: true
greedy: true,
},
string: [
{
pattern: /(?:'(?:''|[^'\r\n])*'(?!')|#[&$%]?[a-f\d]+)+|\^[a-z]/i,
greedy: true,
},
{
pattern: /(?:"(?:""|[^"\r\n])*"(?!")|#[&$%]?[a-f\d]+)+|\^[a-z]/i,
greedy: true,
},
],
});
},
});
Expand Down

0 comments on commit eec01b0

Please sign in to comment.