@@ -94,8 +94,8 @@ macro_rules! push_err_and_continue {
9494pub fn event_handler < L : IntoCallbackLabel , A : Args , C : Context , R : Runtime > (
9595 world : & mut World ,
9696 params : & mut SystemState < (
97- EventReader < ScriptCallbackEvent < A > > ,
98- Res < CallbackSettings < A , C , R > > ,
97+ EventReader < ScriptCallbackEvent > ,
98+ Res < CallbackSettings < C , R > > ,
9999 Res < ContextLoadingSettings < C , R > > ,
100100 Res < Scripts > ,
101101 Query < ( Entity , Ref < ScriptComponent > ) > ,
@@ -232,6 +232,7 @@ mod test {
232232 use crate :: {
233233 event:: CallbackLabel ,
234234 handler:: HandlerFn ,
235+ prelude:: ScriptValue ,
235236 script:: { Script , ScriptId } ,
236237 } ;
237238
@@ -249,20 +250,20 @@ mod test {
249250 }
250251
251252 struct TestContext {
252- pub invocations : Vec < String > ,
253+ pub invocations : Vec < ScriptValue > ,
253254 }
254255
255256 fn setup_app < L : IntoCallbackLabel + ' static , A : Args , C : Context , R : Runtime > (
256- handler_fn : HandlerFn < A , C , R > ,
257+ handler_fn : HandlerFn < C , R > ,
257258 runtime : R ,
258259 contexts : HashMap < u32 , C > ,
259260 scripts : HashMap < ScriptId , Script > ,
260261 ) -> App {
261262 let mut app = App :: new ( ) ;
262263
263- app. add_event :: < ScriptCallbackEvent < A > > ( ) ;
264+ app. add_event :: < ScriptCallbackEvent > ( ) ;
264265 app. add_event :: < ScriptErrorEvent > ( ) ;
265- app. insert_resource :: < CallbackSettings < A , C , R > > ( CallbackSettings {
266+ app. insert_resource :: < CallbackSettings < C , R > > ( CallbackSettings {
266267 callback_handler : Some ( handler_fn) ,
267268 } ) ;
268269 app. add_systems ( Update , event_handler :: < L , A , C , R > ) ;
@@ -301,7 +302,7 @@ mod test {
301302 } ;
302303 let mut app = setup_app :: < OnTestCallback , String , TestContext , TestRuntime > (
303304 |args, entity, script, _, ctxt, _, runtime, _| {
304- ctxt. invocations . push ( args) ;
305+ ctxt. invocations . extend ( args) ;
305306 runtime. invocations . push ( ( entity, script. clone ( ) ) ) ;
306307 Ok ( ( ) )
307308 } ,
@@ -314,11 +315,10 @@ mod test {
314315 . spawn ( ScriptComponent ( vec ! [ test_script_id. clone( ) ] ) )
315316 . id ( ) ;
316317
317- app. world_mut ( )
318- . send_event ( ScriptCallbackEvent :: < String > :: new_for_all (
319- OnTestCallback :: into_callback_label ( ) ,
320- "test_args" . to_owned ( ) ,
321- ) ) ;
318+ app. world_mut ( ) . send_event ( ScriptCallbackEvent :: new_for_all (
319+ OnTestCallback :: into_callback_label ( ) ,
320+ vec ! [ ScriptValue :: String ( "test_args" . into( ) ) ] ,
321+ ) ) ;
322322 app. update ( ) ;
323323
324324 let test_context = app
@@ -336,7 +336,7 @@ mod test {
336336 . get( & test_ctxt_id)
337337 . unwrap( )
338338 . invocations,
339- vec![ "test_args" ]
339+ vec![ ScriptValue :: String ( "test_args" . into ( ) ) ]
340340 ) ;
341341
342342 assert_eq ! (
@@ -389,7 +389,7 @@ mod test {
389389 } ;
390390 let mut app = setup_app :: < OnTestCallback , String , TestContext , TestRuntime > (
391391 |args, entity, script, _, ctxt, _, runtime, _| {
392- ctxt. invocations . push ( args) ;
392+ ctxt. invocations . extend ( args) ;
393393 runtime. invocations . push ( ( entity, script. clone ( ) ) ) ;
394394 Ok ( ( ) )
395395 } ,
@@ -402,19 +402,17 @@ mod test {
402402 . spawn ( ScriptComponent ( vec ! [ test_script_id. clone( ) ] ) )
403403 . id ( ) ;
404404
405- app. world_mut ( )
406- . send_event ( ScriptCallbackEvent :: < String > :: new (
407- OnTestCallback :: into_callback_label ( ) ,
408- "test_args_script" . to_owned ( ) ,
409- crate :: event:: Recipients :: Script ( test_script_id. clone ( ) ) ,
410- ) ) ;
405+ app. world_mut ( ) . send_event ( ScriptCallbackEvent :: new (
406+ OnTestCallback :: into_callback_label ( ) ,
407+ vec ! [ ScriptValue :: String ( "test_args_script" . into( ) ) ] ,
408+ crate :: event:: Recipients :: Script ( test_script_id. clone ( ) ) ,
409+ ) ) ;
411410
412- app. world_mut ( )
413- . send_event ( ScriptCallbackEvent :: < String > :: new (
414- OnTestCallback :: into_callback_label ( ) ,
415- "test_args_entity" . to_owned ( ) ,
416- crate :: event:: Recipients :: Entity ( test_entity_id) ,
417- ) ) ;
411+ app. world_mut ( ) . send_event ( ScriptCallbackEvent :: new (
412+ OnTestCallback :: into_callback_label ( ) ,
413+ vec ! [ ScriptValue :: String ( "test_args_entity" . into( ) ) ] ,
414+ crate :: event:: Recipients :: Entity ( test_entity_id) ,
415+ ) ) ;
418416
419417 app. update ( ) ;
420418
@@ -433,7 +431,10 @@ mod test {
433431 . get( & test_ctxt_id)
434432 . unwrap( )
435433 . invocations,
436- vec![ "test_args_script" , "test_args_entity" ]
434+ vec![
435+ ScriptValue :: String ( "test_args_script" . into( ) ) ,
436+ ScriptValue :: String ( "test_args_entity" . into( ) )
437+ ]
437438 ) ;
438439
439440 assert_eq ! (
0 commit comments