0
votes

I have a resource pool with only 1 resource unit, I'd like to have a node "myArea" changes its color depending on if the resource unit is idle or busy. I typed the following code in a function "updateColor" body which I call in the resource pool actions "on seize" and "on release" (and in the Main agent "on startup").

int idleUnits = speedyBag.idle();
if (idleUnits == 1){
myArea.setFillColor(Color.GREEN);
} else if (idleUnits == 0) {
myArea.setFillColor(Color.RED);
}

However this code doesn't work as I expected, the simulation starts with a green area but when the resource unit is seized it turns red and stays red forever. I guess with

speedyBag.idle()

I'm not pointing at what i think (the number of idle units in the pool, indicated in the picture). Any suggestions?

image

1

1 Answers

1
votes

No need for your approach, you can just use the dynamic color property of your node. Code below ensures the node fills green if you have 1 or more idle units. If all are busy, it shows red: enter image description here