Playing with unit create, i can't seem to come up with a way to create a unit and automatically assign it to an array. Is this possible without having to declare each variable like:
unit[1][1] = blah
unit[1][2] = superblah
etc
I feel like i have to create the units in one trigger and assign them to their variable in separate triggers.
I understand the editor assigns a unit ID of some sort to each created unit so I was hoping this piece could be simple
The problem i'm having is if i try to declare all units to their array value in map initialization, i get an error saying more or less i have too many triggers. Can i break out where i declare global variables?
I've tried this and failed:
using set variable:
set array[$var][$var2] = unit Point(x,y)
set array[$var][$var2] = unit Point(x+$var3,y)
Create unit returns a unit group, because you can create multiple units with 1 call. So you would need to do something like array[..] = UnitGroupUnit(UnitCreate(...),1)
Quote:
I understand the editor assigns a unit ID of some sort to each created unit so I was hoping this piece could be simple
Unfortunately, we do not have any access to this unit id. We used to, but it got "fixed" aka removed.
If you place the unit manually on the map within the editor, it gets another id to reference it, which we have access to, but that probably does not help you.
Quote:
The problem i'm having is if i try to declare all units to their array value in map initialization, i get an error saying more or less i have too many triggers.Can i break out where i declare global variables?
How big is your array? Declaring the variables should not be the problem, the setting most likely is. You can try to use multiple threads for this.
Quote:
I've tried this and failed:
using set variable:
set array[$var][$var2] = unit Point(x,y)
set array[$var][$var2] = unit Point(x+$var3,y)
but does not work
What does unit Point mean? Creating a unit at that point? This should work in theory.
i still don't understand what and why you doing this. What's the point of creating units and saving them in variables if, at it seems, they are all random without real purpose.
What's the problem of adding last created units to global unit group if you really need them in variables?
If they follow some pattern then and you try to create them in row column like fashion (just guessing what you trying to do)
for each real _r from 0.0 to 99.0 increment 2.0
for each real _c from 0.0 to 99.0 increment 2.0
create 'amount' units A at point (_r*scale,_c*scale) for player 'whatever'
set UnitGroupArray[_r][_c] = LastCreatedUnits
create 'amount' units B at point (_r*scale,_c*scale) for player 'whatever'
set UnitGroupArray[_r+1][_c+1] = LastCreatedUnits
if you create just 1 unit you can use UnitArray instead of unit groups and use LastCreatedUnit. For point you use Point From XY
Playing with unit create, i can't seem to come up with a way to create a unit and automatically assign it to an array. Is this possible without having to declare each variable like:
unit[1][1] = blah
unit[1][2] = superblah
etc
I feel like i have to create the units in one trigger and assign them to their variable in separate triggers.
you could use loops if units repeat themselves but if all are different than there's obviously no other way unless you expect your pc to guess :)
Unless you mean more dynamic storage than you can add them to unit groups
@Nerfpl:
fair enough...what i want to do will involve a loop i can write but more or less
do while (condition) {
array[$var][$var2] = unit_create(marilne)
array[$var][$var2 + 1] = unit_create(marine)
array[$var][$var2 + 2) = unit_create(marine)
}
I understand the editor assigns a unit ID of some sort to each created unit so I was hoping this piece could be simple
The problem i'm having is if i try to declare all units to their array value in map initialization, i get an error saying more or less i have too many triggers. Can i break out where i declare global variables?
I've tried this and failed:
using set variable:
set array[$var][$var2] = unit Point(x,y)
set array[$var][$var2] = unit Point(x+$var3,y)
but does not work
Create unit returns a unit group, because you can create multiple units with 1 call. So you would need to do something like array[..] = UnitGroupUnit(UnitCreate(...),1)
Unfortunately, we do not have any access to this unit id. We used to, but it got "fixed" aka removed.
If you place the unit manually on the map within the editor, it gets another id to reference it, which we have access to, but that probably does not help you.
How big is your array? Declaring the variables should not be the problem, the setting most likely is. You can try to use multiple threads for this.
What does unit Point mean? Creating a unit at that point? This should work in theory.
i still don't understand what and why you doing this. What's the point of creating units and saving them in variables if, at it seems, they are all random without real purpose.
What's the problem of adding last created units to global unit group if you really need them in variables?
If they follow some pattern then and you try to create them in row column like fashion (just guessing what you trying to do)
if you create just 1 unit you can use UnitArray instead of unit groups and use LastCreatedUnit. For point you use Point From XY
@basballguy: Go
You mean like this?
variable number = 0
variable unit[] - no unit
Event - unit is created
Action - set unit[number] == created unit
- set number == number + 1
Easiest method I can think of (in GUI format):