FiguraMC / Figura

Extensively customize your character with Figura!

Home Page:https://modrinth.com/mod/figura

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Custom event registration

alekso56 opened this issue · comments

ok, lets say i have a class implementing FiguraAPI

    @LuaWhitelist
    @LuaFieldDoc("myAPI.myCustomEvent")
    public static final LuaEvent myCustomEvent = new LuaEvent();

i want to be able to call that event on the java side

   myCustomEvent.callOrSomething(varargs);

and listen on the lua side

function myAPI.myCustomEvent()
    log("IM CUSTOM!")
end

just an example, but badly implemented. you can make events api be the hub instead of an external class from another mod.

@alekso56 Adding functions via assignment merely requires defining __newindex for your addon; you can then either use a switch-case (fast for a few events) or reflection (what EventsAPI uses) and register the event there. I'll see if event dispatching is also similarly easy.

@alekso56 Adding functions via assignment merely requires defining __newindex for your addon; you can then either use a switch-case (fast for a few events) or reflection (what EventsAPI uses) and register the event there. I'll see if event dispatching is also similarly easy.

They're referring to something different and I already added an API for what they want

String name = ID + "." + event.getFirst().toUpperCase(Locale.US);

Maybe im misunderstanding but wouldn't using "." in this instance refer to a table making the API useless in lua, if calling from events api?
ie events.MyAPI.MyEvent()
what's the intended call method?
@UnlikePaladin

String name = ID + "." + event.getFirst().toUpperCase(Locale.US);

Maybe im misunderstanding but wouldn't using "." in this instance refer to a table making the API useless in lua, if calling from events api?
ie events.MyAPI.MyEvent()
what's the intended call method?

@alekso56 You could do events["MyAPI.MyEvent"], but I agree that that seems awkward.