Junior Member
Join Date: Apr 2006
Posts: 4
|
Got this question in AB3. Could someone help me with this problem:
A unit of type X must be smaller than every other instance of a unit of type Y. For example: Unit Y1 = 5 models Unit Y2 = 10 models Unit Y3 = 12 models Then Unit X must be 5 models of smaller. How can I implement this in ABv3? Greetings, Richard |
#1 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 8,232
|
You can't enforce this as a fixed behavior, but you can definitely handle this as a validated behavior. First, you'll need to write a hidden statcalc that determines the smallest size unit of type Y. This can be done by having the Test expression only apply to units of type Y and then having the Tally expression update the value to the model count of the unit only if it's smaller than the previous value. Just make sure that you specify a large initial value as the starting value for the statcalc! Once that's done, it's easy to write a rule with "unit" scope that has an explicit "targetid" of unit X. This rule just verifies that the model count of unit X is not larger than the value from the statcalc.
Hope this helps, Rob At 08:35 AM 4/5/2006, you wrote: Quote:
|
|
#2 |
Junior Member
Join Date: Apr 2006
Posts: 4
|
Thanx. I solved the smallest unit problem too.
Did this: Made a statcalc rule with entity scope. (S1_SmUn) ---------------- Value is 999 to start with. TEST expression: Tested on a unit with TAG: S1_help.Y TALLY expression: if (@value > entity.count[model]) then @value = entity.count[model] endif --------------- Then made a new rule: (S1_SmUn) -------------- again entity scope. TEST expression: unit with TAG: S1_help.X SCRIPT: var A as number A = statcalc[S1_SmUn] if (A = 999) then @valid=0 else if (entity.count[model] < A) then @valid=1 else @valid=0 endif endif --> where the first if-then looks of there any X unit in the roster at all. The second if-then looks if the Y unit is the smaller than the return value of statcalc. |
#3 |
|
|