Compare commits
	
		
			3 commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | fa70abac23 | ||
| 41d0fd57f3 | |||
|   | e430795dce | 
					 5 changed files with 24 additions and 26 deletions
				
			
		|  | @ -1,7 +1,7 @@ | |||
| [package] | ||||
| name = "bevy_scriptum" | ||||
| authors = ["Jaroslaw Konik <konikjar@gmail.com>"] | ||||
| version = "0.9.0" | ||||
| version = "0.9.1" | ||||
| edition = "2024" | ||||
| license = "MIT OR Apache-2.0" | ||||
| readme = "README.md" | ||||
|  |  | |||
							
								
								
									
										27
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								README.md
									
									
									
									
									
								
							|  | @ -3,21 +3,19 @@ | |||
|  | ||||
| 
 | ||||
| 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 | ||||
| 
 | ||||
| | language/runtime | cargo feature | documentation chapter                                           | | ||||
| | ---------------- | ------------- | --------------------------------------------------------------- | | ||||
| | 🌙 LuaJIT        | `lua`         | [link](https://jarkonik.github.io/bevy_scriptum/lua/lua.html)   | | ||||
| | 🌾 Rhai          | `rhai`        | [link](https://jarkonik.github.io/bevy_scriptum/rhai/rhai.html) | | ||||
| | 💎 Ruby          | `ruby`        | [link](https://jarkonik.github.io/bevy_scriptum/ruby/ruby.html) | | ||||
| | language/runtime                           | cargo feature | documentation chapter                                           | | ||||
| | ------------------------------------------ | ------------- | --------------------------------------------------------------- | | ||||
| | 🌙 LuaJIT                                  | `lua`         | [link](https://jarkonik.github.io/bevy_scriptum/lua/lua.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) | | ||||
| 
 | ||||
| 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/) 🧑💻 | ||||
| 
 | ||||
| bevy_scriptum's main advantages include: | ||||
| 
 | ||||
| - low-boilerplate | ||||
| - easy to use | ||||
| - asynchronicity with a promise-based API | ||||
|  | @ -27,7 +25,6 @@ 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. | ||||
| 
 | ||||
| All you need to do is register callbacks on your Bevy app like this: | ||||
| 
 | ||||
| ```rust | ||||
| use bevy::prelude::*; | ||||
| use bevy_scriptum::prelude::*; | ||||
|  | @ -42,9 +39,7 @@ App::new() | |||
|     }) | ||||
|     .run(); | ||||
| ``` | ||||
| 
 | ||||
| And you can call them in your scripts like this: | ||||
| 
 | ||||
| ```lua | ||||
| hello_bevy() | ||||
| ``` | ||||
|  | @ -75,7 +70,6 @@ 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: | ||||
| 
 | ||||
| ```rust | ||||
| use bevy::prelude::*; | ||||
| use bevy_scriptum::prelude::*; | ||||
|  | @ -93,9 +87,7 @@ App::new() | |||
|     }) | ||||
|     .run(); | ||||
| ``` | ||||
| 
 | ||||
| which you can then call in your script like this: | ||||
| 
 | ||||
| ```lua | ||||
| fun_with_string_param("Hello world!") | ||||
| ``` | ||||
|  | @ -164,18 +156,17 @@ You should then see `my_print: 'Hello world!'` printed in your console. | |||
| 
 | ||||
| ### Provided examples | ||||
| 
 | ||||
| You can also try running provided examples by cloning this repository and running `cargo run --example <example_name>_<language_name>`. For example: | ||||
| You can also try running provided examples by cloning this repository and running `cargo run --example <example_name>_<language_name>`.  For example: | ||||
| 
 | ||||
| ```bash | ||||
| cargo run --example hello_world_lua | ||||
| ``` | ||||
| 
 | ||||
| The examples live in `examples` directory and their corresponding scripts live in `assets/examples` directory within the repository. | ||||
| 
 | ||||
| ### Bevy compatibility | ||||
| 
 | ||||
| | bevy version | bevy_scriptum version | | ||||
| | ------------ | --------------------- | | ||||
| |--------------|-----------------------| | ||||
| | 0.16         | 0.8-0.9               | | ||||
| | 0.15         | 0.7                   | | ||||
| | 0.14         | 0.6                   | | ||||
|  | @ -193,7 +184,6 @@ get_player_name():and_then(function(name) | |||
|     print(name) | ||||
| end) | ||||
| ``` | ||||
| 
 | ||||
| which will print out `John` when used with following exposed function: | ||||
| 
 | ||||
| ```rust | ||||
|  | @ -206,7 +196,7 @@ App::new() | |||
|    .add_scripting::<LuaRuntime>(|runtime| { | ||||
|            runtime.add_function(String::from("get_player_name"), || String::from("John")); | ||||
|    }); | ||||
| ``` | ||||
| ```` | ||||
| 
 | ||||
| ## Access entity from script | ||||
| 
 | ||||
|  | @ -214,7 +204,6 @@ A variable called `entity` is automatically available to all scripts - it repres | |||
| It exposes `index` property that returns bevy entity index. | ||||
| It is useful for accessing entity's components from scripts. | ||||
| It can be used in the following way: | ||||
| 
 | ||||
| ```lua | ||||
| print("Current entity index: " .. entity.index) | ||||
| ``` | ||||
|  |  | |||
|  | @ -1,5 +1,7 @@ | |||
| # Installation | ||||
| 
 | ||||
| Ruby is currently only supported on Linux. | ||||
| 
 | ||||
| ## Ruby | ||||
| 
 | ||||
| To build `bevy_scriptum` with Ruby support a Ruby installation is needed to be | ||||
|  |  | |||
|  | @ -1,3 +1,4 @@ | |||
| # Ruby | ||||
| 
 | ||||
| This chapter demonstrates how to work with bevy_scriptum when using Ruby language runtime. | ||||
| Ruby is currently only supported on Linux. | ||||
|  |  | |||
							
								
								
									
										18
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/lib.rs
									
									
									
									
									
								
							|  | @ -4,11 +4,11 @@ | |||
| 
 | ||||
| //! ## Supported scripting languages/runtimes
 | ||||
| //!
 | ||||
| //! | language/runtime  | cargo feature | documentation chapter                                           |
 | ||||
| //! | ----------------- | ------------- | --------------------------------------------------------------- |
 | ||||
| //! | 🌙 LuaJIT         | `lua`         | [link](https://jarkonik.github.io/bevy_scriptum/lua/lua.html)   |
 | ||||
| //! | 🌾 Rhai           | `rhai`        | [link](https://jarkonik.github.io/bevy_scriptum/rhai/rhai.html) |
 | ||||
| //! | 💎 Ruby           | `ruby`        | [link](https://jarkonik.github.io/bevy_scriptum/ruby/ruby.html) |
 | ||||
| //! | language/runtime                           | cargo feature | documentation chapter                                           |
 | ||||
| //! | ------------------------------------------ | ------------- | --------------------------------------------------------------- |
 | ||||
| //! | 🌙 LuaJIT                                  | `lua`         | [link](https://jarkonik.github.io/bevy_scriptum/lua/lua.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) |
 | ||||
| //!
 | ||||
| //! Documentation book is available [here](https://jarkonik.github.io/bevy_scriptum/) 📖
 | ||||
| //!
 | ||||
|  | @ -510,7 +510,7 @@ impl<R: Runtime> Default for Callbacks<R> { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| #[cfg(debug_assertions)] | ||||
| #[cfg(all(debug_assertions, unix))] | ||||
| pub extern "C" fn is_rdynamic_linking() -> bool { | ||||
|     unsafe { | ||||
|         // Get a function pointer to itself
 | ||||
|  | @ -524,6 +524,12 @@ pub extern "C" fn is_rdynamic_linking() -> bool { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| #[cfg(any(not(debug_assertions), not(unix)))] | ||||
| pub extern "C" fn is_rdynamic_linking() -> bool { | ||||
|     // On Windows or in release builds, return a default value
 | ||||
|     true | ||||
| } | ||||
| 
 | ||||
| pub mod prelude { | ||||
|     pub use crate::{BuildScriptingRuntime as _, Runtime as _, Script}; | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue