Skip to content

🐛 Sending a callback event on the same frame as AddStaticScript it fails #469

@Ownezx

Description

@Ownezx

Summary

I would want to load a script and execute a callback on the same frame. For instance, I load a scenario and I want to trigger the on_scenario_start function.

commands.queue(AddStaticScript::new(handle.clone()));
events.write(ScriptCallbackEvent::new_for_all_scripts(
    OnTest,
    vec![],
));

I get :

2025-08-28T22:10:18.921977Z ERROR bevy_mod_scripting_core::handler: error in script `id AssetId<bevy_mod_scripting_core::asset::ScriptAsset>{ index: 0, generation: 0}`: Missing context for script id AssetId<bevy_mod_scripting_core::asset::ScriptAsset>{ index: 0, generation: 0}. Was the script loaded?..
Context:
Lua

Reproducing

https://github.com/Ownezx/bms_min_repro/issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions