Python Basics - ID to Plot

Lplate

Esus (Allegedly)
Joined
Feb 8, 2011
Messages
578
Location
Ireland
Hi,

If I have the integer ID of a Unit, what function do I use to get the plot that the Unit is on?

thanks,
LPlate
 
Assuming you know the player id (since two units from different players can have the same ID), you can do it like this:

Code:
# ePlayer is the player ID
# iUnit is the unit ID

pPlayer = gc.getPlayer(ePlayer)
pUnit = pPlayer.getUnit(iUnit)
pPlot = pUnit.plot()

pPlot is of type CyPlot, and you can get everything you need from it.
 
Thanks Asaf,

It's working now. I thought I might need to use the player id also.

LPlate
 
Player ID is the same as PlayerType, which is represented by the ePlayer value in this case.
 
Back
Top Bottom