Tests
This commit is contained in:
parent
fe63d62f02
commit
a05dc89132
|
|
@ -565,18 +565,6 @@ dependencies = [
|
||||||
"thiserror",
|
"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]]
|
[[package]]
|
||||||
name = "bevy_gizmos"
|
name = "bevy_gizmos"
|
||||||
version = "0.13.2"
|
version = "0.13.2"
|
||||||
|
|
@ -986,6 +974,18 @@ dependencies = [
|
||||||
"thiserror",
|
"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]]
|
[[package]]
|
||||||
name = "bevy_sprite"
|
name = "bevy_sprite"
|
||||||
version = "0.13.2"
|
version = "0.13.2"
|
||||||
|
|
|
||||||
15
Cargo.toml
15
Cargo.toml
|
|
@ -1,8 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bevy_github_ci_template"
|
name = "bevy_scripting_tests"
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0 OR CC0-1.0"
|
|
||||||
|
|
||||||
# Compile with Performance Optimizations:
|
# Compile with Performance Optimizations:
|
||||||
# https://bevyengine.org/learn/book/getting-started/setup/#compile-with-performance-optimizations
|
# https://bevyengine.org/learn/book/getting-started/setup/#compile-with-performance-optimizations
|
||||||
|
|
@ -17,11 +15,16 @@ opt-level = 3
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy_mod_scripting = { git = "https://github.com/makspll/bevy_mod_scripting", features = [
|
bevy_mod_scripting = { git = "https://github.com/makspll/bevy_mod_scripting", features = [
|
||||||
"lua54", "lua",
|
"lua54",
|
||||||
|
"lua",
|
||||||
"lua_script_api",
|
"lua_script_api",
|
||||||
], rev = "c497b432b53e7d" }
|
], rev = "c497b432b53e7d" }
|
||||||
bevy_mod_scripting_core = { git = "https://github.com/makspll/bevy_mod_scripting", 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_mod_scripting_lua = { git = "https://github.com/makspll/bevy_mod_scripting", rev = "c497b432b53e7d", features = [
|
||||||
bevy_script_api = { git = "https://github.com/makspll/bevy_mod_scripting", rev ="c497b432b53e7d", features= ["lua"] }
|
"lua54",
|
||||||
|
] }
|
||||||
|
bevy_script_api = { git = "https://github.com/makspll/bevy_mod_scripting", rev = "c497b432b53e7d", features = [
|
||||||
|
"lua",
|
||||||
|
] }
|
||||||
bevy = { version = "0.13.1", features = ["multi-threaded"] }
|
bevy = { version = "0.13.1", features = ["multi-threaded"] }
|
||||||
rand = "0.8.5"
|
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 life_state = world:get_component(entity, LifeState)
|
||||||
local cells = life_state.cells
|
local cells = life_state.cells
|
||||||
|
|
||||||
|
super_print("Hey, it's me, a Lua!")
|
||||||
|
|
||||||
-- set some cells alive
|
-- set some cells alive
|
||||||
for _ = 1, 10000 do
|
for _ = 1, 10000 do
|
||||||
local index = math.random(#cells)
|
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 ScriptContext = Mutex<Lua>;
|
||||||
type DocTarget = LuaDocFragment;
|
type DocTarget = LuaDocFragment;
|
||||||
|
|
||||||
fn attach_api(&mut self, _: &mut Self::APITarget) -> Result<(), ScriptError> {
|
fn attach_api(&mut self, ctx: &mut Self::APITarget) -> Result<(), ScriptError> {
|
||||||
// we don't actually provide anything global
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<body style="margin: 0px;">
|
<body style="margin: 0px;">
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import './restart-audio-context.js'
|
import './restart-audio-context.js'
|
||||||
import init from './bevy_game.js'
|
import init from './bevy_scripting_tests.js'
|
||||||
|
|
||||||
init().catch((error) => {
|
init().catch((error) => {
|
||||||
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an 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