Skip to content

Commit

Permalink
minor docs updates
Browse files Browse the repository at this point in the history
  • Loading branch information
x87 committed Dec 26, 2022
1 parent 4109d26 commit 0f30722
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 15 deletions.
14 changes: 10 additions & 4 deletions docs/en/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

> This feature is highly experimental and might be unstable.
- [Async API](#async-api)
- [Async Functions](#async-functions)
- [Concurrent Async Functions](#concurrent-async-functions)
- [Dynamic Imports](#dynamic-imports)
- [setTimeout and setInterval](#settimeout-and-setinterval)

CLEO Redux supports asynchronous code via [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) and `async/await` syntax. This enables lots of advanced code patterns.

Note that asynchoronous programming is a fairly complex topic and if you want to learn more about visit the following resources:
Expand All @@ -13,7 +19,7 @@ See an example of an async script for GTA III [here](https://github.com/x87/luig

## Async API

CLEO Redux 1.0.4 has one native async command: `asyncWait`. This command is used to pause a script for a specified amount of time. It returns a `Promise` that resolves after the specified amount of time. `asyncWait` can only be used inside a `async` function.
CLEO Redux 1.0.4 has one native async command: `asyncWait`. This command pauses the script for a specified amount of time. It returns a `Promise` that resolves after the specified amount of time. `asyncWait` can only be used inside an `async` function.

```js
async function delay(ms) {
Expand All @@ -25,7 +31,7 @@ async function delay(ms) {
delay(1000);
```

Difference between `asyncWait` and `wait` is that the former is not a blocking command. If you don't put the `await` keyword in front of it, the script execution will continue.
Difference between `asyncWait` and `wait` is that the former is not a blocking command. If you don't put the `await` keyword in front of it, the script execution continues.

```js
async function delay(ms) {
Expand Down Expand Up @@ -122,7 +128,7 @@ async function task3() {
```

This is very similar to writing traditional `while(true){}` loops with a `wait` command in it, with the difference that the functions must have `async` keyword and use `asyncWait` instead of `wait`
Each of the three tasks are executed independently from each other. Note that runtime guarantees that all async functions are executed in the same thread. They could share global variables and mutate them. Look at how `gVar` is incremented in `task2` and read in `task3`.
Each of the three tasks are executed independently from each other. Note that runtime guarantees that all async functions are executed in the same thread. They share global variables and can change them. Look at how `gVar` is being incremented in `task2` and read in `task3`.

## Dynamic Imports

Expand Down Expand Up @@ -166,4 +172,4 @@ When importing JSON files, its content is available via `default` property.

## setTimeout and setInterval

It is easy to implement `setTimeout` and `setInterval` using `asyncWait` and `async` functions. You can [find an implementation example here](https://github.com/cleolibrary/CLEO-Redux/blob/master/examples/setTimeout%2C%20setInterval.js).
It is easy to implement `setTimeout` and `setInterval` using `asyncWait` and `async` functions. You can [find an implementation example here](https://github.com/cleolibrary/CLEO-Redux/blob/master/examples/setTimeout%2C%20setInterval.js).
5 changes: 3 additions & 2 deletions docs/en/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ CLEO Redux exposes some of the configurable settings in the file `CLEO\.config\c
- `AllowCs` - when set to `1` CLEO loads and executes `*.cs` files located in the [CLEO directory](./cleo-directory.md). Enabled by default.
- `AllowJs` - when set to `1` CLEO loads and executes `*.js` files located in the [CLEO directory](./cleo-directory.md). Enabled by default.
- `AllowFxt` - when set to `1` CLEO loads and [uses](./using-fxt.md) `*.fxt` files located in the CLEO\CLEO_TEXT directory. Enabled by default.
- `CheckUpdates` - (deprecated in favor of [Frontend](./installation-plugins.md) plugin)
- `LogOpcodes` - when set to `1` CLEO [logs](./log.md) all executed opcodes in custom scripts.
- `DisplayMenuInfo` - when set to `1` CLEO displays some information in the main menu. Enabled by default.
- `PermissionLevel` - sets the [permission level](./permissions.md) for unsafe operations (see below). Default is `Lax`.

- `CheckUpdates` - (deprecated in favor of [Frontend](./installation-plugins.md) plugin)
- `DisplayMenuInfo` - (deprecated in favor of [Frontend](./installation-plugins.md) plugin)

## Host

- `EnableSelfHost` - when set to `1` CLEO runs in the self-host mode. Only applicable on an Unknown host. See the [Emdedding](./embedding.md) guide for more information.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ To stream events in your terminal while testing a script, run:
tail -f cleo_redux.log
```

`tail` is a unix command so a compatible environment is needed (for example Git Bash).
`tail` is a unix command so a compatible environment is needed (for example [Git Bash](https://git-scm.com/downloads)).

The log file also lists all executed opcodes with [`LogOpcodes=1`](./config.md#general) and JavaScript commands with [`CLEO.debug.trace(true)`](./api.md#cleo).
4 changes: 2 additions & 2 deletions docs/en/the-definitive-edition-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ In short, yes. [See this page](https://github.com/cleolibrary/CLEO-Redux/wiki/Fe

### Can I use original opcodes?

Yes, you can. Refer to the Sanny Builder library https://library.sannybuilder.com/#/sa_unreal. Take a note that some opcodes have been changed from the classic games, so don't expect everything to work like it was in classic. If you run into an issue, find help in [our Discord](https://discord.gg/d5dZSfgBZr).
Yes, you can. Refer to the [Sanny Builder library](https://library.sannybuilder.com/#/sa_unreal). Keep in mind that some opcodes have been changed from the classic games, so don't expect everything to work like it was in classic. If you run into an issue, find help in [our Discord](https://discord.gg/d5dZSfgBZr).

### How do I know what commands can I use in JavaScript?

After each game run, CLEO generates a d.ts file in the CLEO\.config directory. It's called gta3.d.ts, vc.d.ts or sa.d.ts depending on the game. This file lists all supported functions and methods that you can use in JavaScript code.
After each game run, CLEO generates a `.d.ts` file in the `CLEO\.config` directory. It's called `gta3.d.ts`, `vc.d.ts` or `sa.d.ts` depending on the game. This file lists all supported functions and methods that you can use in JavaScript code.

To enable autocomplete in VS Code include the following line in your JS script:

Expand Down
2 changes: 1 addition & 1 deletion docs/en/unsupported.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following items are known to be not working and there is no specific timelin

## Unsupported features in JS

- commands requiring an scm variable (e.g. countdown timers). [Tracking issue](https://github.com/cleolibrary/CLEO-Redux/issues/10).
- for commands requiring a global SCM variable (e.g. countdown timers) use [scm.ts library](https://github.com/x87/scm.ts).

- commands implicitly loading models or textures (such as widgets) [Tracking issue](https://github.com/cleolibrary/CLEO-Redux/issues/12). You can circumvent the issue by preloading needed resources, e.g. by calling them in a .CS script first.

Expand Down
6 changes: 3 additions & 3 deletions docs/en/using-memory-64.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
> This guide is for x64 hosts (e.g. the remastered trilogy). For the information on using the Memory class on x86 (classic era games) [click here](./using-memory.md).
# Memory Object (x64)

> This guide is for x64 hosts (e.g. the remastered trilogy). For the information on using the Memory class on x86 (classic era games) [click here](./using-memory.md).
- [Reading and Writing Values](#reading-and-writing-values)
- [Reading and Writing Strings](#reading-and-writing-strings)
- [Casting methods](#casting-methods)
- [Calling Foreign Functions](#calling-foreign-functions)
- [Convenience methods with Fn object](#convenience-methods-with-fn-object)
- [Convenience methods with Fn object](#convenience-methods-with-fn-object)

An intrinsic object `Memory` provides methods for accessing and manipulating the data or code in the current process. It has the following interface:

Expand Down
4 changes: 2 additions & 2 deletions docs/en/using-memory.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
> This guide is for x86 hosts (such as classic era games). For the information on using the Memory class on x64 hosts (such as the Definitive edition) [click here](./using-memory-64.md).
# Memory Object

> This guide is for x86 hosts (such as classic era games). For the information on using the Memory class on x64 hosts (such as the Definitive edition) [click here](./using-memory-64.md).
- [Reading and Writing Values](#reading-and-writing-values)
- [Reading and Writing Strings](#reading-and-writing-strings)
- [Casting methods](#casting-methods)
Expand Down

0 comments on commit 0f30722

Please sign in to comment.