Variable(s)

Paladin

New Member
Reaction score
8
I want to make a variable that gets added by one every time a unit enters the game. But, I also want to catch the person who made it and what type of unit it is.

How do I do this without making so many variables?


Thanks to anyone who helps and +rep :)
 

Tom Jones

N/A
Reaction score
437
This one will keep track of as many units as the size of the two arrays:
Code:
Test
    Events
        Unit - A unit enters (Playable map area)
    Conditions
    Actions
        Set Unit_Count = (Unit_Count + 1)
        Set Unit_Type[Unit_Count] = (Unit-type of (Triggering unit))
        Set Unit_Owner[Unit_Count] = (Owner of (Triggering unit))
 

Paladin

New Member
Reaction score
8
This one will keep track of as many units as the size of the two arrays:
Code:
Test
    Events
        Unit - A unit enters (Playable map area)
    Conditions
    Actions
        Set Unit_Count = (Unit_Count + 1)
        Set Unit_Type[Unit_Count] = (Unit-type of (Triggering unit))
        Set Unit_Owner[Unit_Count] = (Owner of (Triggering unit))


If every time I trained a unit then, wouldn't the Unit Owner and Unit Type change?
 

ManyTimes

I'm so lonesome I could cry...
Reaction score
293
>>If every time I trained a unit then, wouldn't the Unit Owner and Unit Type change?

What? If you create 1 unit for player 1 red, then create another one for player 1 red, the owner has changed? Doubt it.

If you got some triggers you have started on, please show us, simply select the trigger you want to show us in the trigger editor > EDIT (top menu) > "Copy as text" > Paste in a post.

Just for the fun of it, no need to track the player that owns the unit. If you got a unit and you can track the unit, you already "know" the owner of it (can get the owner of it), no matter if you change owner of the unit or whatever. Which mean, the player variable is not needed, at all. Same then goes for the unit type, I would rather just have a "unit"-variable with arrays...then you can get both the owner of that unit and its type.

But tell us what you want to do with these units, would help a bit...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top