Ruby support #1
5 changed files with 43 additions and 10 deletions
|
|
@ -9,7 +9,7 @@ _test:
|
||||||
test: build-deps _test
|
test: build-deps _test
|
||||||
|
|
||||||
test-watch: build-deps
|
test-watch: build-deps
|
||||||
watchexec --exts md just _test
|
watchexec --exts md -r just _test
|
||||||
|
|
||||||
serve:
|
serve:
|
||||||
mdbook serve
|
mdbook serve
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,10 @@
|
||||||
To call a rust function from Lua first you need to register a function
|
To call a rust function from Lua first you need to register a function
|
||||||
within Rust using builder pattern.
|
within Rust using builder pattern.
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
|
# extern crate bevy;
|
||||||
|
# extern crate bevy_scriptum;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
@ -20,7 +23,10 @@ fn main() {
|
||||||
|
|
||||||
For example to register a function called `my_rust_func` you can do the following:
|
For example to register a function called `my_rust_func` you can do the following:
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
|
# extern crate bevy;
|
||||||
|
# extern crate bevy_scriptum;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
@ -49,7 +55,10 @@ that implements `FromLua`.
|
||||||
Since a registered callback function is a Bevy system, the parameters are passed
|
Since a registered callback function is a Bevy system, the parameters are passed
|
||||||
to it as `In` struct with tuple, which has to be the first parameter of the closure.
|
to it as `In` struct with tuple, which has to be the first parameter of the closure.
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
|
# extern crate bevy;
|
||||||
|
# extern crate bevy_scriptum;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
@ -68,7 +77,10 @@ fn main() {
|
||||||
|
|
||||||
To make it look nicer you can destructure the `In` struct.
|
To make it look nicer you can destructure the `In` struct.
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
|
# extern crate bevy;
|
||||||
|
# extern crate bevy_scriptum;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
@ -97,7 +109,10 @@ Any registered rust function that returns a value will retrurn a promise when
|
||||||
called within a script. By calling `:and_then` on the promise you can register
|
called within a script. By calling `:and_then` on the promise you can register
|
||||||
a callback that will receive the value returned from Rust function.
|
a callback that will receive the value returned from Rust function.
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
|
# extern crate bevy;
|
||||||
|
# extern crate bevy_scriptum;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,10 @@ of the function to call, `LuaScriptData` that has been automatically
|
||||||
attached to entity after an entity with script attached has been spawned
|
attached to entity after an entity with script attached has been spawned
|
||||||
and its script evaluated, the entity and optionally some arguments.
|
and its script evaluated, the entity and optionally some arguments.
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
|
# extern crate bevy;
|
||||||
|
# extern crate bevy_scriptum;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
@ -36,7 +39,10 @@ fn main() {}
|
||||||
We can also pass some arguments by providing a tuple or `Vec` as the last
|
We can also pass some arguments by providing a tuple or `Vec` as the last
|
||||||
`call_fn` argument.
|
`call_fn` argument.
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
|
# extern crate bevy;
|
||||||
|
# extern crate bevy_scriptum;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,10 @@ a create feature.
|
||||||
|
|
||||||
You can now start exposing functions to the scripting language. For example, you can expose a function that prints a message to the console:
|
You can now start exposing functions to the scripting language. For example, you can expose a function that prints a message to the console:
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
|
# extern crate bevy;
|
||||||
|
# extern crate bevy_scriptum;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
@ -40,7 +43,10 @@ my_print("Hello world!")
|
||||||
|
|
||||||
And spawn an entity with attached `Script` component with a handle to a script source file:
|
And spawn an entity with attached `Script` component with a handle to a script source file:
|
||||||
|
|
||||||
```rust
|
```rust,no_run
|
||||||
|
# extern crate bevy;
|
||||||
|
# extern crate bevy_scriptum;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@ To spawn a Lua script you will need to get a handle to a script asset using
|
||||||
bevy's `AssetServer`.
|
bevy's `AssetServer`.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
# extern crate bevy;
|
||||||
|
# extern crate bevy_scriptum;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
@ -24,6 +27,9 @@ been attached to will get the `Script::<LuaScript>` component stripped and inste
|
||||||
So to query scipted entities you could do something like:
|
So to query scipted entities you could do something like:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
# extern crate bevy;
|
||||||
|
# extern crate bevy_scriptum;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
use bevy_scriptum::runtimes::lua::prelude::*;
|
use bevy_scriptum::runtimes::lua::prelude::*;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue