Skip to content

Macroless Lua Function Registration #61

@vurvdev

Description

@vurvdev

Is your feature request related to a problem? Please describe.
Problem: Using a wrapper macro is not ideal when registering a native function with autorun-lua

Describe the solution you'd like
To be able to just pass functions which use dependency injection to get their parameters, ie the LuaApi, etc, and can return anything that implements LuaReturn which will automatically be anything IntoLua or RawLuaReturn.

Aka, you should be able to do this.

fn give_me_five(lua: &LuaApi, state: *mut LuaState) -> i32 {
    return 5;
}

fn main(...) {
    let globals = lua.globals(state);
    lua.set(state, &globals, "giveMeFive", give_me_five); // notice the lack of a as_lua_function! macro
}

This notably does NOT include the ability to have parameters built-in as sugar, ie args: (impl FromLua...) just to keep it simple. It can be done after this.

Describe alternatives you've considered
No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions