| 10-08-2007, 09:11 PM | #1 |
JASS:if ( udg_xr2 == udg_xr ) then call GroupAddUnitSimple( u, udg_xg2 ) call DisplayTextToForce( GetPlayersAll(), ( "= " + R2S(udg_xr2)) ) call DisplayTextToForce( GetPlayersAll(), ( "num " + I2S(CountUnitsInGroup(udg_xg2)) ) ) else if ( udg_xb == false ) then if ( udg_xr2 < udg_xr ) then call DisplayTextToForce( GetPlayersAll(), ( "< " + R2S(udg_xr2)) ) call DestroyGroup(udg_xg2) set udg_xg2 = null set udg_xr = udg_xr2 call GroupAddUnitSimple( u, udg_xg2 ) endif else if ( udg_xr2 > udg_xr ) then call DisplayTextToForce( GetPlayersAll(), ( "> " + R2S(udg_xr2)) ) call DestroyGroup(udg_xg2) set udg_xg2 = null set udg_xr = udg_xr2 call GroupAddUnitSimple( u, udg_xg2 ) endif endif endif For each unit (local u in function sub_gor which is running under ForGroupBJ), it gets a real (xr2), and checks if it is equal to the current value (xr). If so, it adds the unit to a group(xg2). If not, it checks if it should be looking for higher or lower(xb), and then checks if that value is. If so, it destroys the current group(xg2), and adds the unit to it afterwards, starting a new group under the new value. According to the messages, the script works fine, but xg2 is always empty. You can see above I add the unit to ag2, and then I display the count, it always comes up 0. |
| 10-09-2007, 08:11 AM | #2 |
You are working with null groups. First you need to set ugd_xg2 = CreateGroup() of course. And instead of GroupAddUnitSimple which is just a bj wrapper, GroupAddUnit should be used. |
| 10-09-2007, 11:52 PM | #3 |
How come the compiler never does stuff like this... "CreateGroup()". Does setting a group to something also create it? Thanks, I will try that. PS: Optimizer removes all the BJs automatically right? |
| 10-10-2007, 07:32 PM | #4 |
No. |
| 10-10-2007, 08:44 PM | #5 |
No to? |
| 10-10-2007, 08:45 PM | #6 |
Setting it to CreateGroup(), I believe, makes a new group and sets the variable to it. |
| 10-10-2007, 09:12 PM | #7 | ||
Quote:
Well, the compiler can't just add random code to your script. It doesn't know what you're trying to achieve. Quote:
Setting it to something other than null will make the group variable usable. Setting it to CreateGroup() is a good option because it will give you a fresh, new, empty group. |
| 10-10-2007, 10:50 PM | #8 |
No to "PS: Optimizer removes all the BJs automatically right?" |
