OVERLORDTRANSPORT not recognized
I receive this error:
KeyError: <UnitTypeId.OVERLORDTRANSPORT: 893>
only for this unit in unit_typeid.py
I have a dictionary of units like:
ENEMY_DRAW_DICT = {
NEXUS: [4, (0, 0, 255)],
ASSIMILATOR: [2, (4, 10, 255)],
CYBERNETICSCORE: [3, (8, 20, 255)],
OVERLORDTRANSPORT: [1, (59, 230, 240)],
...
}
Later in a draw method, I use the unit's name to reference the size & color in my dictionary. I only have a problem with OVERLORDTRANSPORT
# draw method
unit_name = enemy_unit.name.upper()
cv2.circle(
game_data,
(int(pos[0]), int(pos[1])),
ENEMY_DRAW_DICT[UnitTypeId[unit_name]][0],
ENEMY_DRAW_DICT[UnitTypeId[unit_name]][1],
-1
)
ENEMY_DRAW_DICT[UnitTypeId[unit_name]][0], => should returns 1
Would appreciate debugging/ help on this. Cheers
OVERLORD is what you want, not OVERLORDTRANSPORT, also say hi to sentdex
@vgainullin Thank you! Will try when back tonight. If I forgot to include OVERLORD, then we definitely need a different error for this.
And will do haha
To confirm OVERLORD was included. The error occurs when we have a dropperlord come into view. Again this isn't happening with any other unit_id constant. I think there is something wrong with OVERLORDTRANSPORT as a constant in unit_typeid.py or where ever is is used after that.
Your code should look like this:
ENEMY_DRAW_DICT = { NEXUS: [4, (0, 0, 255)], ASSIMILATOR: [2, (4, 10, 255)], CYBERNETICSCORE: [3, (8, 20, 255)], OVERLORD: [1, (59, 230, 240)], ... }
And draw method something like this:
async def intel(self) for unit in self.units.ready: pos = unit.position unit_type = str(unit.name).upper() if unit_type in ENEMY_DRAW_DICT : ud = ENEMY_DRAW_DICT [unit_type] cv2.circle(game_data, (int(pos[0]), int(pos[1])), ud[0], (ud[1][0], ud[1][1], ud[1][2]), -1) # BGR