How do I store an agent in a variable?

Im trying to use a trigger_device to get what player triggered the device, and then save them in a variable that i can then access later in other parts of the code. But i cant really find a way to make an variable that stores an empty agent to begin with.
This is my code atm (get errors when i try to set Queen to ValidAgent since its not the same type):

    @editable ClassTrigger : trigger_device = trigger_device{}

    var Queen : ?agent = false

    Trigger(Agent : ?agent): void =
        if (ValidAgent := Agent?):
            set Queen = ValidAgent

    OnBegin<override>()<suspends>:void=
        RoundStarter.BeganEvent.Subscribe(OnRoundStarted)
1 Like

When the data type is optional, you need to use the option{} marco to assign non-optional values. Here is an example:

set Queen = option{ValidAgent}
1 Like