How to check if a resuource type is present

skodkim

Deity
Joined
Jan 16, 2004
Messages
2,497
Location
Denmark
Hi

working on some small ransom events for Civ V and would like to make a check to see if a number of resource types are present on a plot. Furthermore I'd like the plot to be improved.

I've got a string looking like this but somehow it never "activates"

Spoiler :
return city and (plot:GetResourceType() == GameInfo.Resources[ "RESOURCE_COW" ].ID or plot:GetResourceType() == GameInfo.Resources[ "RESOURCE_SHEEP" ].ID or plot:GetResourceType() == GameInfo.Resources[ "RESOURCE_DEER" ].ID or plot:GetResourceType() == GameInfo.Resources[ "RESOURCE_BANANA" ].ID or plot:GetResourceType() == GameInfo.Resources[ "RESOURCE_FISH" ].ID or plot:GetResourceType() == GameInfo.Resources[ "RESOURCE_WHEAT" ].ID) and not plot:GetImprovementType() == -1;


I'm only slight familiar with lua but as far as I can tell this should work.

Can anyone give me some help on this.

\Skodkim
 
Well, instead of
GameInfo.Resources[ "RESOURCE_COW" ].ID
you can just do
GameInfoTypes.RESOURCE_COW
It means the same thing, and keeps you from using quotes, brackets, etc. which means less chance for an unmatched set.

As for the rest, it'd depend on your definition of "plot". Are you sure it's actually picking the right plot to check?
 
Back
Top Bottom