jarkonik / bevy_scriptum

📜 A plugin for Bevy that allows you to write some of your game logic in a scripting language.
https://jarkonik.github.io/bevy_scriptum/
Apache License 2.0
84 stars 4 forks source link

Single argument function calls dont work. #33

Open dgriffith0 opened 3 months ago

dgriffith0 commented 3 months ago

On Main branch calling with a single argument tuple or single argument in either direction doesn't work.

Calling Rust from Lua

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_scripting::<LuaRuntime>(|runtime| {
             runtime.add_function(String::from("func_with_params"), |In((a)): In<(i64)>| {
                  //doesnt compile trait bounds not satisfied.
             });
        })
        .run();
}

Calling Lua from Rust

fn call_lua_on_update_from_rust(
    mut scripted_entities: Query<(Entity, &mut LuaScriptData)>,
    scripting_runtime: ResMut<LuaRuntime>,
) {
    for (entity, mut script_data) in &mut scripted_entities {
        scripting_runtime
            .call_fn("on_update", &mut script_data, entity, (123)) //FuncArgs not satisfied
            .unwrap();
    }
}

function on_update(a)
    print(a) -- 123
end

Calling Lua from Rust will work if I replace the single argument tuple with a vec e.g. vec![123]