Disabling Settlers for AI

Joined
Sep 28, 2008
Messages
402
Location
United States
Quick question, I want to be able to disable settlers for the AI. Using this code the AI seems to still be producing settlers... So what am I doing wrong?

Spoiler :
Code:
function NoAISettler(ownerID, cityID, unitTypeID)
	local player = Players[ownerID]
	local unit = GameInfo.Units[unitTypeID]	

	if not (player:IsHuman()) and (unitTypeID == GameInfo.Units["UNIT_SETTLER"].ID) then
		return false
	end
		return true
end
GameEvents.CityCanTrain.Add(NoAISettler)
 
Is that code in a lua file on its own and if so, is there an InGameUIAddin entry for the file?

That is, do you know for sure that the event is being caught and executing that code.

Enable logging and stick a print("This is the NoAISettler listener") as the first line of the function and then check the lua.log file
 
Top Bottom