I am using subscribe to create callbacks on all my devices in the level. One thing I would like to do is know which device the callback is coming from, however it seems verse does not want me to pass additional parameters (such as an int) into the callback of my subscribe.
The only other way I can think of doing this would be to create an individual callback for every single device which would hurt my soul
Code here:
@editable
var CaptureDevices : []capture_area_device = array{}
OnBegin<override>()<suspends>:void=
for (CaptureDevice : CaptureDevices):
CaptureDevice.ControlChangeEvent.Subscribe(OnCaptureAreaChangeOwner)
OnCaptureAreaChangeOwner(InPlayer : agent): void =
Print("Capture area taken")
#Do something depending on which capture device was captured
You can’t, it’s a severe limitation of Verse at the moment. I’m sure somebody is working on it though. What you can do is wrap them up in a custom class and then call out from that class (as we can’t make proper listeners yet either…)
# Handler for a button InteractedWithEvent but could be used for any listenable requiring a (agent -> void) signature
on_prop_pickedup_function := type{_(:agent, :int) : void}
pickup_prop_button_handler := class:
AdditionalData: int
Callback: on_prop_pickedup_function
HandleInteractedWithEvent(Agent:agent):void=
Callback(Agent, AdditionalData)
Or you could use spawn as a quick lightweight solution
for (CaptureDevice : CaptureDevices):
spawn{WaitForZoneToBeCaptured(CaptureDevice)}
WaitForZoneToBeCaptured(CaptureDevice : capture_area_device)<suspends>:void=
loop:
Agent := CaptureDevice.ControlChangeEvent.Await()
# Agent is the new owner