Building which Generates Resource

Starrynite120

Prince
Joined
Jul 15, 2015
Messages
472
I'm trying to get the Growlab to, instead of giving increased yield to fungus, generate a new food resource tile near the city. I could just make a satellite which will produce the resource, which the Growlab grants once built, but I know there's an easier way to do this through lua, I'm just not sure how exactly. Does anyone know how I could get a building to create a resource near the city in which its built upon completion? I know I would use function OnBuildingComplete(playerID, buildingID, cityID, bComplete) and GameEvents.BuildingProcessed.Add(OnBuildingComplete), I'm just unsure how to determine which tile would get the resource. I was thinking I could also use a Random equation to determine which resource is actually generated.
 
It is possible. As you've noted you can used BuildingProcessed to detect when a Growlab is completed. Then you'll need some algorithm that grabs the plot object you want to put the resource on. Once you have a plot object you can use something like:
Code:
local plot = --the plot you want;

if(plot:GetResourceType() == -1) then
  plot:SetResourceType(resourceID, quantity);
end
To give the plot a resource of your choice. Quantity can be 1 in the case on non-strategic resources.

You'll still need to come up with a way (or specification) to go from the city that has built the Growlab to the plot you want to put a resource on.
 
Back
Top Bottom