Skip to content

Commit 7343b31

Browse files
committed
remove extra import, fix lua to_string
1 parent f7ce25b commit 7343b31

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

assets/scripts/game_of_life.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ end
2828
function on_click(x,y)
2929
-- get the settings
3030
world.info("Lua: Clicked at x: " .. x .. " y: " .. y)
31+
print(entity)
3132
local life_state = fetch_life_state()
3233
local cells = life_state.cells
3334

crates/bevy_mod_scripting_functions/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use ::bevy::prelude::*;
2-
use test_functions::register_test_functions;
32
#[cfg(feature = "bevy_bindings")]
43
pub mod bevy_bindings;
54
pub mod core;
@@ -16,7 +15,7 @@ impl Plugin for ScriptFunctionsPlugin {
1615
register_bevy_bindings(app);
1716
register_core_functions(app);
1817
#[cfg(feature = "test_functions")]
19-
register_test_functions(app);
18+
test_functions::register_test_functions(app);
2019

2120
// TODO: if bevy ever does this itself we should remove this
2221
app.world_mut().register_component::<Parent>();

crates/languages/bevy_mod_scripting_lua/src/bindings/reference.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,22 @@ impl UserData for LuaReflectReference {
395395
)?))
396396
});
397397

398-
m.add_meta_function(MetaMethod::ToString, |_, ()| {
398+
m.add_meta_function(MetaMethod::ToString, |_, self_: LuaReflectReference| {
399399
let world = ThreadWorldContainer.get_world();
400+
let reflect_reference: ReflectReference = self_.into();
400401

401-
let func = lookup_function(world, [TypeId::of::<ReflectReference>()], "display")
402-
.expect("No 'display' function registered for a ReflectReference");
403-
404-
Ok(LuaScriptValue(ScriptValue::Function(func)))
402+
let func = lookup_function(
403+
world.clone(),
404+
[TypeId::of::<ReflectReference>()],
405+
"display_ref",
406+
)
407+
.expect("No 'display' function registered for a ReflectReference");
408+
let out = func.call(
409+
vec![ScriptValue::Reference(reflect_reference)],
410+
world,
411+
LUA_CALLER_CONTEXT,
412+
)?;
413+
Ok(LuaScriptValue(out))
405414
// let mut display_func =
406415
// lookup_dynamic_function_typed::<ReflectReference>(lua, "display_ref")
407416
// .expect("No 'display' function registered for a ReflectReference");

0 commit comments

Comments
 (0)