| 02-12-2004, 07:38 AM | #1 |
I have only been using jass for a couple days, and have been doing so to take advantage of locals. I mainly am just converting to custom text and inserting into GUI for what I'm trying to do right now. I need to pick all units around a unit (target) but not the unit (target), my problem is it isn't letting my use my locals i have created inside the pick units in GUI (i know why, thats not the question), then i need to call a function with the picked units and another local unit. How can i do this? |
| 02-12-2004, 09:43 AM | #2 |
Yes, (well, if i understand you right). Pick Units and do actions is a pain... But a DataAngel created a GENIOUS life-saving function which "simulates" a pick-all-units-in-a-group and do action. How you use it, is: you create a group, f.ex. using a local group variable. f.ex. Code:
local group MyGroup = GetUnitsInRangeOfLocAll( 300, udg_MyLocation ) You also create a local unit variable called sumtin like "TempUnit", plus a "i" integer variable (just a counter). Then when you wannna pick all units etc etc, you just do a loop like this: Code:
set i = 0 loop set TempUnit = IterateGroup( MyGroup, i ) exitwhen TempUnit == null *actions-using-TempUnit-for-the-currently-picked-unit* *more actions* *as many actions as you want* set i = i + 1 endloop //optional: call DestroyGroup( MyGroup ) The main feature of using "IterateGroup" and this stuff, is that it allows you to use "local" variables inside the actions-part. Hope This helps Cubasis |
| 02-12-2004, 10:12 AM | #3 |
That worked, it was exactly what i needed. An odd thing happened though, it did the actions for some of the units twice. Thanks for your help. |
| 02-12-2004, 11:13 AM | #4 |
erhm, that's wierd o_O, Only thing i can think of, is ,,, erhm.... in the actions you are "changing" the group... like adding a unit or removing a unit from it o_O Anyways, Cubasis |
| 02-12-2004, 12:04 PM | #5 |
Ok found the problem, set i = 1 instead of 0. |
