How to subscribe to an event with a <suspends> function

I have a function called ‘LockOn’ that makes a guard that spawns maintain focus on the player. But I can’t figure out how to make a function that subscribe to an event.

The ‘MaintainFocus’ function is what requires the ‘Focus’ function to have .

Is there any way to an asynchronous function subscribe to an event?
I appreciate any advice. Thanks! :pray:

image

The error message states:
This function parameter expects a value of type agent->void, but this argument is an incompatible value of type type{_(:agent):void}.

You can’t directly put a function with suspends effect on epic-made devices. You might want to use spawn{} inside a function with no suspends effect on it so you can call that function. Here is an example:

LockOn_start(Guard: agent): void=
     spawn{LockOn(Guard)}
5 Likes

Worked like a charm. Thanks!

1 Like

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