File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed
bevy_mod_scripting_functions/src
languages/bevy_mod_scripting_lua/src/bindings Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 28
28
function on_click (x ,y )
29
29
-- get the settings
30
30
world .info (" Lua: Clicked at x: " .. x .. " y: " .. y )
31
+ print (entity )
31
32
local life_state = fetch_life_state ()
32
33
local cells = life_state .cells
33
34
Original file line number Diff line number Diff line change 1
1
use :: bevy:: prelude:: * ;
2
- use test_functions:: register_test_functions;
3
2
#[ cfg( feature = "bevy_bindings" ) ]
4
3
pub mod bevy_bindings;
5
4
pub mod core;
@@ -16,7 +15,7 @@ impl Plugin for ScriptFunctionsPlugin {
16
15
register_bevy_bindings ( app) ;
17
16
register_core_functions ( app) ;
18
17
#[ cfg( feature = "test_functions" ) ]
19
- register_test_functions ( app) ;
18
+ test_functions :: register_test_functions ( app) ;
20
19
21
20
// TODO: if bevy ever does this itself we should remove this
22
21
app. world_mut ( ) . register_component :: < Parent > ( ) ;
Original file line number Diff line number Diff line change @@ -395,13 +395,22 @@ impl UserData for LuaReflectReference {
395
395
) ?) )
396
396
} ) ;
397
397
398
- m. add_meta_function ( MetaMethod :: ToString , |_, ( ) | {
398
+ m. add_meta_function ( MetaMethod :: ToString , |_, self_ : LuaReflectReference | {
399
399
let world = ThreadWorldContainer . get_world ( ) ;
400
+ let reflect_reference: ReflectReference = self_. into ( ) ;
400
401
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) )
405
414
// let mut display_func =
406
415
// lookup_dynamic_function_typed::<ReflectReference>(lua, "display_ref")
407
416
// .expect("No 'display' function registered for a ReflectReference");
You can’t perform that action at this time.
0 commit comments