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 {
417
417
let func = ( move |caller_context: CallerContext , world: WorldCallbackAccess , args: Vec <ScriptValue > | {
418
418
let res: Result <ScriptValue , InteropError > = ( || {
419
419
let expected_arg_count = count!( $( $param ) * ) ;
420
- if args. len( ) != expected_arg_count {
420
+ if args. len( ) < expected_arg_count {
421
421
return Err ( InteropError :: function_call_error( FunctionError :: ArgCountMismatch {
422
422
expected: expected_arg_count,
423
423
received: args. len( )
Original file line number Diff line number Diff line change @@ -304,7 +304,7 @@ pub fn register_reflect_reference_functions(
304
304
. register ( "iter" , |w : WorldCallbackAccess , s : ReflectReference | {
305
305
let mut infinite_iter = s. into_iter_infinite ( ) ;
306
306
let world = w. try_read ( ) . expect ( "stale world" ) ;
307
- let iter_function = move |w : WorldCallbackAccess | {
307
+ let iter_function = move || {
308
308
let ( next_ref, idx) = infinite_iter. next_ref ( ) ;
309
309
let allocator = world. allocator ( ) ;
310
310
let mut allocator = allocator. write ( ) ;
Original file line number Diff line number Diff line change @@ -310,10 +310,15 @@ impl UserData for LuaReflectReference {
310
310
feature = "luajit52" ,
311
311
) ) ]
312
312
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" )
314
314
. expect ( "No iter function registered" ) ;
315
+ let world = l. get_world ( ) ;
315
316
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
+ ) ?) )
317
322
} ) ;
318
323
319
324
// #[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")
2
2
local res = world .get_resource (res_type )
3
3
4
4
iterated_vals = {}
5
- for i ,v in pairs (res .vec_usize )
5
+ for i ,v in pairs (res .vec_usize ) do
6
6
interated_vals [i ] = v
7
7
end
8
8
You can’t perform that action at this time.
0 commit comments