How would I get the stability of a unit given its coordinates?
I’m aware that it’s mentioned in the docs, but I can’t seem to make it work/understand. This is what I’m using but it always returns stability as being 60, even if it’s current stability isn’t.
The key line here: or an empty list if there are no units at the location.
This means you need to check and make sure there is a unit before getting the first one. So:
units = game_state.game_map[x, y] #units is now a list of all units at that location
if len(units) > 0: # make sure there are units at that location
for unit in units: # loop through all units at that location
stability = unit.stability # get that units stability