Tests
This commit is contained in:
parent
fe63d62f02
commit
a05dc89132
|
|
@ -565,18 +565,6 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_github_ci_template"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"bevy_mod_scripting",
|
||||
"bevy_mod_scripting_core",
|
||||
"bevy_mod_scripting_lua",
|
||||
"bevy_script_api",
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_gizmos"
|
||||
version = "0.13.2"
|
||||
|
|
@ -986,6 +974,18 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_scripting_tests"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"bevy_mod_scripting",
|
||||
"bevy_mod_scripting_core",
|
||||
"bevy_mod_scripting_lua",
|
||||
"bevy_script_api",
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_sprite"
|
||||
version = "0.13.2"
|
||||
|
|
|
|||
15
Cargo.toml
15
Cargo.toml
|
|
@ -1,8 +1,6 @@
|
|||
[package]
|
||||
name = "bevy_github_ci_template"
|
||||
version = "0.1.0"
|
||||
name = "bevy_scripting_tests"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0 OR CC0-1.0"
|
||||
|
||||
# Compile with Performance Optimizations:
|
||||
# https://bevyengine.org/learn/book/getting-started/setup/#compile-with-performance-optimizations
|
||||
|
|
@ -17,11 +15,16 @@ opt-level = 3
|
|||
|
||||
[dependencies]
|
||||
bevy_mod_scripting = { git = "https://github.com/makspll/bevy_mod_scripting", features = [
|
||||
"lua54", "lua",
|
||||
"lua54",
|
||||
"lua",
|
||||
"lua_script_api",
|
||||
], rev = "c497b432b53e7d" }
|
||||
bevy_mod_scripting_core = { git = "https://github.com/makspll/bevy_mod_scripting", rev = "c497b432b53e7d" }
|
||||
bevy_mod_scripting_lua = { git = "https://github.com/makspll/bevy_mod_scripting", rev ="c497b432b53e7d" }
|
||||
bevy_script_api = { git = "https://github.com/makspll/bevy_mod_scripting", rev ="c497b432b53e7d", features= ["lua"] }
|
||||
bevy_mod_scripting_lua = { git = "https://github.com/makspll/bevy_mod_scripting", rev = "c497b432b53e7d", features = [
|
||||
"lua54",
|
||||
] }
|
||||
bevy_script_api = { git = "https://github.com/makspll/bevy_mod_scripting", rev = "c497b432b53e7d", features = [
|
||||
"lua",
|
||||
] }
|
||||
bevy = { version = "0.13.1", features = ["multi-threaded"] }
|
||||
rand = "0.8.5"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
.DEFAULT_GOAL := web_host
|
||||
|
||||
web_build:
|
||||
@echo "TEST"
|
||||
cargo build --target wasm32-unknown-unknown
|
||||
|
||||
web_host: web_build
|
||||
@echo "TEST2"
|
||||
wasm-bindgen --out-dir ./out/ --target web ./target/wasm32-unknown-unknown/debug/bevy_scripting_tests.wasm
|
||||
cp -R assets out/
|
||||
cp wasm/* out/
|
||||
ls -R out
|
||||
lwa_simple_server
|
||||
|
||||
prepare:
|
||||
cargo install lwa_simple_server
|
||||
cargo install wasm-bindgen-cli
|
||||
|
|
@ -5,6 +5,8 @@ function init()
|
|||
local life_state = world:get_component(entity, LifeState)
|
||||
local cells = life_state.cells
|
||||
|
||||
super_print("Hey, it's me, a Lua!")
|
||||
|
||||
-- set some cells alive
|
||||
for _ = 1, 10000 do
|
||||
local index = math.random(#cells)
|
||||
|
|
|
|||
15
src/main.rs
15
src/main.rs
|
|
@ -29,8 +29,19 @@ impl APIProvider for LifeAPI {
|
|||
type ScriptContext = Mutex<Lua>;
|
||||
type DocTarget = LuaDocFragment;
|
||||
|
||||
fn attach_api(&mut self, _: &mut Self::APITarget) -> Result<(), ScriptError> {
|
||||
// we don't actually provide anything global
|
||||
fn attach_api(&mut self, ctx: &mut Self::APITarget) -> Result<(), ScriptError> {
|
||||
let ctx = ctx.get_mut().unwrap();
|
||||
|
||||
ctx.globals()
|
||||
.set(
|
||||
"super_print",
|
||||
ctx.create_function(|_ctx, msg: String| {
|
||||
info!("[MESSAGE FROM OTHER WORLD]: {}", msg);
|
||||
Ok(())
|
||||
})
|
||||
.map_err(ScriptError::new_other)?,
|
||||
)
|
||||
.map_err(ScriptError::new_other)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<body style="margin: 0px;">
|
||||
<script type="module">
|
||||
import './restart-audio-context.js'
|
||||
import init from './bevy_game.js'
|
||||
import init from './bevy_scripting_tests.js'
|
||||
|
||||
init().catch((error) => {
|
||||
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue