Compare commits
1 commit
main
...
win-instal
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d16a43087 |
4 changed files with 58 additions and 19 deletions
19
README.md
19
README.md
|
|
@ -3,19 +3,21 @@
|
||||||

|

|
||||||
|
|
||||||
bevy_scriptum is a a plugin for [Bevy](https://bevyengine.org/) that allows you to write some of your game or application logic in a scripting language.
|
bevy_scriptum is a a plugin for [Bevy](https://bevyengine.org/) that allows you to write some of your game or application logic in a scripting language.
|
||||||
|
|
||||||
### Supported scripting languages/runtimes
|
### Supported scripting languages/runtimes
|
||||||
|
|
||||||
| language/runtime | cargo feature | documentation chapter |
|
| language/runtime | cargo feature | documentation chapter |
|
||||||
| ------------------------------------------ | ------------- | --------------------------------------------------------------- |
|
| ---------------- | ------------- | --------------------------------------------------------------- |
|
||||||
| 🌙 LuaJIT | `lua` | [link](https://jarkonik.github.io/bevy_scriptum/lua/lua.html) |
|
| 🌙 LuaJIT | `lua` | [link](https://jarkonik.github.io/bevy_scriptum/lua/lua.html) |
|
||||||
| 🌾 Rhai | `rhai` | [link](https://jarkonik.github.io/bevy_scriptum/rhai/rhai.html) |
|
| 🌾 Rhai | `rhai` | [link](https://jarkonik.github.io/bevy_scriptum/rhai/rhai.html) |
|
||||||
| 💎 Ruby(currently only supported on Linux) | `ruby` | [link](https://jarkonik.github.io/bevy_scriptum/ruby/ruby.html) |
|
| 💎 Ruby | `ruby` | [link](https://jarkonik.github.io/bevy_scriptum/ruby/ruby.html) |
|
||||||
|
|
||||||
Documentation book is available [here](https://jarkonik.github.io/bevy_scriptum/) 📖
|
Documentation book is available [here](https://jarkonik.github.io/bevy_scriptum/) 📖
|
||||||
|
|
||||||
Full API docs are available at [docs.rs](https://docs.rs/bevy_scriptum/latest/bevy_scriptum/) 🧑💻
|
Full API docs are available at [docs.rs](https://docs.rs/bevy_scriptum/latest/bevy_scriptum/) 🧑💻
|
||||||
|
|
||||||
bevy_scriptum's main advantages include:
|
bevy_scriptum's main advantages include:
|
||||||
|
|
||||||
- low-boilerplate
|
- low-boilerplate
|
||||||
- easy to use
|
- easy to use
|
||||||
- asynchronicity with a promise-based API
|
- asynchronicity with a promise-based API
|
||||||
|
|
@ -25,6 +27,7 @@ bevy_scriptum's main advantages include:
|
||||||
Scripts are separate files that can be hot-reloaded at runtime. This allows you to quickly iterate on your game or application logic without having to recompile it.
|
Scripts are separate files that can be hot-reloaded at runtime. This allows you to quickly iterate on your game or application logic without having to recompile it.
|
||||||
|
|
||||||
All you need to do is register callbacks on your Bevy app like this:
|
All you need to do is register callbacks on your Bevy app like this:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
|
|
@ -39,7 +42,9 @@ App::new()
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
```
|
```
|
||||||
|
|
||||||
And you can call them in your scripts like this:
|
And you can call them in your scripts like this:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
hello_bevy()
|
hello_bevy()
|
||||||
```
|
```
|
||||||
|
|
@ -70,6 +75,7 @@ App::new()
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also pass arguments to your callback functions, just like you would in a regular Bevy system - using `In` structs with tuples:
|
You can also pass arguments to your callback functions, just like you would in a regular Bevy system - using `In` structs with tuples:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_scriptum::prelude::*;
|
use bevy_scriptum::prelude::*;
|
||||||
|
|
@ -87,7 +93,9 @@ App::new()
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
```
|
```
|
||||||
|
|
||||||
which you can then call in your script like this:
|
which you can then call in your script like this:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
fun_with_string_param("Hello world!")
|
fun_with_string_param("Hello world!")
|
||||||
```
|
```
|
||||||
|
|
@ -161,12 +169,13 @@ You can also try running provided examples by cloning this repository and runnin
|
||||||
```bash
|
```bash
|
||||||
cargo run --example hello_world_lua
|
cargo run --example hello_world_lua
|
||||||
```
|
```
|
||||||
|
|
||||||
The examples live in `examples` directory and their corresponding scripts live in `assets/examples` directory within the repository.
|
The examples live in `examples` directory and their corresponding scripts live in `assets/examples` directory within the repository.
|
||||||
|
|
||||||
### Bevy compatibility
|
### Bevy compatibility
|
||||||
|
|
||||||
| bevy version | bevy_scriptum version |
|
| bevy version | bevy_scriptum version |
|
||||||
|--------------|-----------------------|
|
| ------------ | --------------------- |
|
||||||
| 0.16 | 0.8-0.9 |
|
| 0.16 | 0.8-0.9 |
|
||||||
| 0.15 | 0.7 |
|
| 0.15 | 0.7 |
|
||||||
| 0.14 | 0.6 |
|
| 0.14 | 0.6 |
|
||||||
|
|
@ -184,6 +193,7 @@ get_player_name():and_then(function(name)
|
||||||
print(name)
|
print(name)
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
which will print out `John` when used with following exposed function:
|
which will print out `John` when used with following exposed function:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
|
@ -196,7 +206,7 @@ App::new()
|
||||||
.add_scripting::<LuaRuntime>(|runtime| {
|
.add_scripting::<LuaRuntime>(|runtime| {
|
||||||
runtime.add_function(String::from("get_player_name"), || String::from("John"));
|
runtime.add_function(String::from("get_player_name"), || String::from("John"));
|
||||||
});
|
});
|
||||||
````
|
```
|
||||||
|
|
||||||
## Access entity from script
|
## Access entity from script
|
||||||
|
|
||||||
|
|
@ -204,6 +214,7 @@ A variable called `entity` is automatically available to all scripts - it repres
|
||||||
It exposes `index` property that returns bevy entity index.
|
It exposes `index` property that returns bevy entity index.
|
||||||
It is useful for accessing entity's components from scripts.
|
It is useful for accessing entity's components from scripts.
|
||||||
It can be used in the following way:
|
It can be used in the following way:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
print("Current entity index: " .. entity.index)
|
print("Current entity index: " .. entity.index)
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,24 @@
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
Ruby is currently only supported on Linux.
|
|
||||||
|
|
||||||
## Ruby
|
## Ruby
|
||||||
|
|
||||||
To build `bevy_scriptum` with Ruby support a Ruby installation is needed to be
|
To build `bevy_scriptum` with Ruby support a Ruby installation is needed to be
|
||||||
present on your development machine.
|
present on your development machine.
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
#### Requirements
|
||||||
|
|
||||||
|
- clang
|
||||||
|
- Ruby installation compiled with clang
|
||||||
|
|
||||||
|
#### Clang installation
|
||||||
|
|
||||||
|
For `clang` installation instruction consult your
|
||||||
|
OS vendor provided documentation or [clang official webiste](https://clang.llvm.org).
|
||||||
|
|
||||||
|
#### Ruby installation
|
||||||
|
|
||||||
The easiest way to produce a compatible Ruby installation is to use [rbenv](https://rbenv.org/).
|
The easiest way to produce a compatible Ruby installation is to use [rbenv](https://rbenv.org/).
|
||||||
|
|
||||||
After installing `rbenv` along with its `ruby-build` plugin you can build and
|
After installing `rbenv` along with its `ruby-build` plugin you can build and
|
||||||
|
|
@ -17,8 +29,6 @@ CC=clang rbenv install 3.4.4
|
||||||
```
|
```
|
||||||
|
|
||||||
Above assumes that you also have `clang` installed on your system.
|
Above assumes that you also have `clang` installed on your system.
|
||||||
For `clang` installation instruction consult your
|
|
||||||
OS vendor provided documentation or [clang official webiste](https://clang.llvm.org).
|
|
||||||
|
|
||||||
If you rather not use `rbenv` you are free to supply your own installation of
|
If you rather not use `rbenv` you are free to supply your own installation of
|
||||||
Ruby provided the following is true about it:
|
Ruby provided the following is true about it:
|
||||||
|
|
@ -28,7 +38,26 @@ Ruby provided the following is true about it:
|
||||||
- it is accessible as `ruby` within `PATH` or `RUBY` environment variable is set
|
- it is accessible as `ruby` within `PATH` or `RUBY` environment variable is set
|
||||||
to path of desired `ruby` binary.
|
to path of desired `ruby` binary.
|
||||||
|
|
||||||
## Main Library
|
### Windows
|
||||||
|
|
||||||
|
#### Requirements
|
||||||
|
|
||||||
|
- clang
|
||||||
|
- Ruby
|
||||||
|
|
||||||
|
#### Clang installation
|
||||||
|
|
||||||
|
Clang can be installed on Windows using `Visual Studio Installer`(select `Desktop
|
||||||
|
Development With C++ ->> C++ Clang tool for Windows` package).
|
||||||
|
|
||||||
|
`LIBCLANG_PATH` environment variable also has to be set to clang installation `bin`
|
||||||
|
directory when compiling. This typically is `C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\x64\lib`.
|
||||||
|
|
||||||
|
#### Ruby installation
|
||||||
|
|
||||||
|
On Windows Ruby can be installed using [RubyInstaller](https://rubyinstaller.org/) among others.
|
||||||
|
|
||||||
|
## bevy_scriptum
|
||||||
|
|
||||||
Add the following to your `Cargo.toml`:
|
Add the following to your `Cargo.toml`:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
# Ruby
|
# Ruby
|
||||||
|
|
||||||
This chapter demonstrates how to work with bevy_scriptum when using Ruby language runtime.
|
This chapter demonstrates how to work with bevy_scriptum when using Ruby language runtime.
|
||||||
Ruby is currently only supported on Linux.
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
//! ## Supported scripting languages/runtimes
|
//! ## Supported scripting languages/runtimes
|
||||||
//!
|
//!
|
||||||
//! | language/runtime | cargo feature | documentation chapter |
|
//! | language/runtime | cargo feature | documentation chapter |
|
||||||
//! | ------------------------------------------ | ------------- | --------------------------------------------------------------- |
|
//! | ----------------- | ------------- | --------------------------------------------------------------- |
|
||||||
//! | 🌙 LuaJIT | `lua` | [link](https://jarkonik.github.io/bevy_scriptum/lua/lua.html) |
|
//! | 🌙 LuaJIT | `lua` | [link](https://jarkonik.github.io/bevy_scriptum/lua/lua.html) |
|
||||||
//! | 🌾 Rhai | `rhai` | [link](https://jarkonik.github.io/bevy_scriptum/rhai/rhai.html) |
|
//! | 🌾 Rhai | `rhai` | [link](https://jarkonik.github.io/bevy_scriptum/rhai/rhai.html) |
|
||||||
//! | 💎 Ruby(currently only supported on Linux) | `ruby` | [link](https://jarkonik.github.io/bevy_scriptum/ruby/ruby.html) |
|
//! | 💎 Ruby | `ruby` | [link](https://jarkonik.github.io/bevy_scriptum/ruby/ruby.html) |
|
||||||
//!
|
//!
|
||||||
//! Documentation book is available [here](https://jarkonik.github.io/bevy_scriptum/) 📖
|
//! Documentation book is available [here](https://jarkonik.github.io/bevy_scriptum/) 📖
|
||||||
//!
|
//!
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue