I have issues with the following problem in AnyLogic:
I would like to create an event that is connected to a changing value of another variable. That variable can wheter be 1 or -1. At any moment it changes from -1 to 1, that event shall be triggered, but only once per occasion. Does anyone have a solution for this?
I already thought about implementing an boolean that checks that change, but I wouldn't know how.
You need to approach this the other way around.
You are trying to "monitor" the variable and wait for a change of it.
Instead, you should only allow 1 way to change that variable and add any additional model changes that come from it.
In OOP, you do it by:
myVariableto access levelprivatepublicfunctionsetMyVariable(int newValue)next to itmyVariable = newValue;AND any other code you want to be triggered whenevernewValue==1ornewValue==-1myVariableis only ever changed via the functionsetMyVariable(...)