| 09-26-2006, 03:31 PM | #1 |
Is this posible in JASS, I been working using globals to solve this problem, but its annoying cuz i have a lot of globals that i only unse once, and everytime i want to import a trigger i have to be looking for the globals too Do this: JASS:function Test_Group takes integer str retunrs nothing call SetHeroStr(GetEnumUnit(), str) endfunction function Trig_Test takes nothing returns nothing local group g = //Heros (as a sample) local integer str = 1 call ForGroup(g, function Test_Group(str)) endfunction Instead of this: JASS:function Test_Group takes nothing retunrs nothing call SetHeroStr(GetEnumUnit(), udg_str) endfunction function Trig_Test takes nothing returns nothing local group g = //Heros (as a sample) set udg_str = 1 call ForGroup(g, function Test_Group) endfunction Thanks ![]() EDIT: yeah i forgot to clean the leaks |
| 09-26-2006, 03:46 PM | #2 |
No. You can't pass it like this. You can use something like CSCache but that's not needed here since there is another way : JASS:function Trig_Test takes nothing returns nothing local group g = //Some random group local unit f loop set f = FirstOfGroup(g) exitwhen f == null //Your code goes here call GroupRemoveUnit(g,f) endloop // And so on. //P.S. : Don't forget to remove the leaks endfunction |
| 09-26-2006, 03:46 PM | #3 |
No you can't do that. My (not yet publically released) tool/preprocessor/etc has that functionality though. It has basic callback functionality for exactly the cases you displayed. (And a more advanced method discovered but yet unimplemented). |
| 09-26-2006, 04:08 PM | #4 |
for that sample, you can just do this iteration: JASS:function Trig_Test takes nothing returns nothing local group g = //Heros (as a sample) local integer str = 1 local unit picked call GroupAddUnit(g,null) //fixes a weird bug loop set picked=FirstOfGroup(g) exitwhen (picked==null) call GroupRemoveUnit(g,picked) call SetHeroStr(picked,str) endloop endfunction no requirement for the extra function call overhead |
| 09-26-2006, 06:20 PM | #5 |
karukef : whatever. you actually can, but it's irrational. I don't see a reason to use the natives anyway. Vex, what's this weird bug ? |
| 09-26-2006, 06:54 PM | #6 |
well if the group was created way before the iteration, and you used RemoveUnit on units that were in that group, then FirstOfGroup might return wrong values, but a single GroupAddUnit(g,null) fixes the nulls in the group. |
