SubsribeAgent with 3 arguments - is it possible?

Hello! I’m trying to make custom function like SubscribeAgent. But I want to make it with 3 arguments… Maybe someone know how I can do it?

(Listenable : listenable(agent)).SubscribeAgent(OutputFunc : tuple(agent, t)->void, ExtraData : t where t:type) : cancelable =
    Wrapper := wrapper_agent(t){ExtraData := ExtraData, OutputFunc := OutputFunc}
    Listenable.Subscribe(Wrapper.InputFunc)
    
wrapper_agent(t : type) := class():
    ExtraData : t;
    OutputFunc : tuple(agent, t) -> void
    InputFunc(Agent : agent):void = OutputFunc(Agent, ExtraData)

I have this code, but I have error:

(Listenable : listenable(agent)).SubscribeRemote(OutputFunc : tuple(agent, t, t, t)->void, ExtraData : t where t:type) : cancelable =
    Wrapper := wrapper_remote(t){ExtraData := ExtraData, ExtraData1 := ExtraData, ExtraData2 := ExtraData, OutputFunc := OutputFunc}
    Listenable.Subscribe(Wrapper.InputFunc)
    
wrapper_remote(t : type) := class():
    ExtraData : t;
    ExtraData1 : t;
    ExtraData2 : t;
    OutputFunc : tuple(agent, t, t, t) -> void
    InputFunc(Agent : agent):void = OutputFunc(Agent, ExtraData, ExtraData1, ExtraData2)

ERROR:
This function parameter expects a value of type tuple(listenable(agent),tuple(),tuple(tuple(agent,false,false,false)->void,any)), but this argument is an incompatible value of type tuple(listenable(agent),tuple(),tuple(tuple(agent,int,int,char)->void,type{0},type{1},char)).(3509)

If you want to send multiple arguments with this wrapper, the easiest way is to pack them inside a tuple.

For example:

Button.InteractedWithEvent().SubscribeAgent(OnButtonPressed, (Arg1, Arg2, Arg3))

OnButtonPressed(Agent:agent, Args:tuple(int, int, int)):void=
    # Do Stuff Here

Make sure to update the types in the Args:tuple(int, int, int) to the type of data you’re sending. Hope this helps

2 Likes

Thank you so much <3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.