File tree Expand file tree Collapse file tree 4 files changed +10
-5
lines changed
bevy_mod_scripting_core/src/bindings/function
bevy_mod_scripting_functions/src
languages/bevy_mod_scripting_lua Expand file tree Collapse file tree 4 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -417,7 +417,7 @@ macro_rules! impl_script_function {
417417 let func = ( move |caller_context: CallerContext , world: WorldCallbackAccess , args: Vec <ScriptValue > | {
418418 let res: Result <ScriptValue , InteropError > = ( || {
419419 let expected_arg_count = count!( $( $param ) * ) ;
420- if args. len( ) != expected_arg_count {
420+ if args. len( ) < expected_arg_count {
421421 return Err ( InteropError :: function_call_error( FunctionError :: ArgCountMismatch {
422422 expected: expected_arg_count,
423423 received: args. len( )
Original file line number Diff line number Diff line change @@ -304,7 +304,7 @@ pub fn register_reflect_reference_functions(
304304 . register ( "iter" , |w : WorldCallbackAccess , s : ReflectReference | {
305305 let mut infinite_iter = s. into_iter_infinite ( ) ;
306306 let world = w. try_read ( ) . expect ( "stale world" ) ;
307- let iter_function = move |w : WorldCallbackAccess | {
307+ let iter_function = move || {
308308 let ( next_ref, idx) = infinite_iter. next_ref ( ) ;
309309 let allocator = world. allocator ( ) ;
310310 let mut allocator = allocator. write ( ) ;
Original file line number Diff line number Diff line change @@ -310,10 +310,15 @@ impl UserData for LuaReflectReference {
310310 feature = "luajit52" ,
311311 ) ) ]
312312 m. add_meta_function ( MetaMethod :: Pairs , |l, s : LuaReflectReference | {
313- let iter_func = lookup_function_typed :: < ReflectReference > ( l, "iter" )
313+ let mut iter_func = lookup_dynamic_function_typed :: < ReflectReference > ( l, "iter" )
314314 . expect ( "No iter function registered" ) ;
315+ let world = l. get_world ( ) ;
315316
316- Ok ( iter_func)
317+ Ok ( LuaScriptValue :: from ( iter_func. call_script_function (
318+ vec ! [ ScriptValue :: Reference ( s. into( ) ) ] ,
319+ world,
320+ lua_caller_context ( ) ,
321+ ) ?) )
317322 } ) ;
318323
319324 // #[cfg(any(
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ local res_type = world.get_type_by_name("TestResourceWithVariousFields")
22local res = world .get_resource (res_type )
33
44iterated_vals = {}
5- for i ,v in pairs (res .vec_usize )
5+ for i ,v in pairs (res .vec_usize ) do
66 interated_vals [i ] = v
77end
88
You can’t perform that action at this time.
0 commit comments