I would like to get the the agent which has just left the delay-block. I do not want to use on at exit if it is not necessary. So basically I want to use on exit and it gives back the agent which just left.
So for example the console says: "The agent that just left is ….", given that there is a System.out….. in the on exit.
I do not have a good idea sadly.
>Solution :
- Create a variable
lastAgentLeft
of the type that your agents actually are (assumeMyAgent
here) - in the
Delay
‘s "on at exit" code box, writelastAgentLeft = agent;
That’s it. Now you can access the last agent always (by accessing that variable). Just make sure to test if any agent has actually left, for example by testing if (lastAgentLeft != null)
(or fold that into a getter function)