Inspired by AOM's Botanist Mod I wanted to create a Farmer Unit that can Plant Resources (Without gathering them). So Far, I got that to work! Now I want to specify the Mechanic of planting the resources, like some Resources can only be planted by a specific Civilization (TraitType) and having a PrereqTech/PrereqCivic. I have tryed to do that via the New Table that lets you plant the Resources, but I get no results. I can still plant a Resource by any Civilization despite I have specifyed it to only be planted by a specific Civilization (with TraitType) and the PrereqTech/Civic doesn't work neather. Here is the Complete SQL Code: Code: create table Farmer_Resources( ResourceType varchar(100), UnitType varchar(100) null, ImprovementType varchar(100) null, PrereqTech varchar(100) null, PrereqCivic varchar(100) null, TraitType varchar(100) null, FOREIGN KEY (PrereqTech) REFERENCES Technologies (TechnologyType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT, FOREIGN KEY (PrereqCivic) REFERENCES Civics (CivicType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT, FOREIGN KEY (TraitType) REFERENCES Traits (TraitType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT ); insert into Farmer_Resources(ResourceType) select ResourceType from Resources where ResourceType in ( --Base Game 'RESOURCE_BANANAS', 'RESOURCE_RICE', 'RESOURCE_WHEAT', 'RESOURCE_CITRUS', 'RESOURCE_COCOA', 'RESOURCE_COFFEE', 'RESOURCE_COTTON', 'RESOURCE_DYES', 'RESOURCE_INCENSE', 'RESOURCE_SPICES', 'RESOURCE_SUGAR', 'RESOURCE_TEA', 'RESOURCE_TOBACCO', 'RESOURCE_WINE', 'RESOURCE_SILK', -- Rise and Fall 'RESOURCE_OLIVES' ); update Farmer_Resources set ImprovementType = 'IMPROVEMENT_PLANT_'|| replace(ResourceType, 'RESOURCE_',''); update Farmer_Resources set UnitType = 'UNIT_FARMER', ImprovementType = 'IMPROVEMENT_PLANT_'|| replace(ResourceType, 'RESOURCE_',''); insert into Types(Type,Kind) select ImprovementType as Type, 'KIND_IMPROVEMENT' as Kind from Farmer_Resources; insert into Improvements(ImprovementType,Name,Description,Icon,Buildable,CanBuildOutsideTerritory,PlunderType) select ImprovementType, 'LOC_'|| ImprovementType ||'_NAME' as Name, 'LOC_'|| ImprovementType ||'_DESCRIPTION' as Description, 'ICON_IMPROVEMENT_PLANTATION' as Icon, 1 as Buildable, 1 as CanBuildOutsideTerritory, 'PLUNDER_NONE' as PlunderType from Farmer_Resources; insert into Improvement_ValidBuildUnits(ImprovementType,UnitType) select ImprovementType, UnitType from Farmer_Resources; insert into Improvement_ValidTerrains(ImprovementType, TerrainType) select distinct br.ImprovementType, vt.TerrainType from Farmer_Resources br join Resource_ValidTerrains vt on br.ResourceType = vt.ResourceType; insert into Improvement_ValidFeatures(ImprovementType, FeatureType) select distinct br.ImprovementType, vt.FeatureType from Farmer_Resources br join Resource_ValidFeatures vt on br.ResourceType = vt.ResourceType; update Farmer_Resources set PrereqTech = 'TECH_MACHINERY' where ImprovementType = 'IMPROVEMENT_PLANT_BANANAS'; update Farmer_Resources set PrereqTech = 'TECH_MACHINERY' where ImprovementType = 'IMPROVEMENT_PLANT_SILK'; update Farmer_Resources set TraitType = 'TRAIT_CIVILIZATION_PLANT_RESOURCE_BANANAS' where ResourceType = 'RESOURCE_BANANAS'; update Farmer_Resources set TraitType = 'TRAIT_CIVILIZATION_PLANT_RESOURCE_SILK' where ResourceType = 'RESOURCE_SILK'; INSERT INTO Types (Type, Kind) VALUES ('TRAIT_CIVILIZATION_PLANT_RESOURCE_BANANAS', 'KIND_TRAIT'), ('TRAIT_CIVILIZATION_PLANT_RESOURCE_SILK', 'KIND_TRAIT'); INSERT INTO Traits (TraitType, Name, Description) VALUES ('TRAIT_CIVILIZATION_PLANT_RESOURCE_BANANAS', 'LOC_TRAIT_CIVILIZATION_PLANT_RESOURCE_BANANAS_NAME', 'LOC_TRAIT_CIVILIZATION_PLANT_RESOURCE_BANANAS_DESCRIPTION'), ('TRAIT_CIVILIZATION_PLANT_RESOURCE_SILK', 'LOC_TRAIT_CIVILIZATION_PLANT_RESOURCE_SILK_NAME', 'LOC_TRAIT_CIVILIZATION_PLANT_RESOURCE_SILK_DESCRIPTION'); INSERT INTO CivilizationTraits (CivilizationType, TraitType) VALUES ('CIVILIZATION_KONGO', 'TRAIT_CIVILIZATION_PLANT_RESOURCE_BANANAS'), ('CIVILIZATION_KONGO', 'TRAIT_CIVILIZATION_PLANT_RESOURCE_SILK'); I have also tryed the TraitType and The Prerqs Without the Foreign Key but no results. Here is The Lua Code (I don't think that it has any effect on this problem, but if it can be of any help, here it is!): Code: include("PopupDialog"); local NONE = -1; function OnImprovementAddedToMap(locationX, locationY, improvementType, eImprovementOwner, resource, isPillaged, isWorked) local plot = Map.GetPlot(locationX,locationY); local improvement = GameInfo.Improvements[improvementType]; if improvement ~=nil then PlantSeeds(improvement,plot); else print('improvement type '..improvementType..' not found'); end end function PlantSeeds(improvement,plot) local found_transplant_type = false; local transplant_types = {}; table.insert(transplant_types,'RESOURCE'); for i in string.gmatch(improvement.ImprovementType, "[^_]+") do if i == 'PLANT' then found_transplant_type = true; elseif found_transplant_type then table.insert(transplant_types,i); end end if found_transplant_type then local transplant_resource_type = table.concat(transplant_types,'_'); ResourceBuilder.SetResourceType(plot, GameInfo.Resources[transplant_resource_type].Index, 1); ImprovementBuilder.SetImprovementType(plot, NONE, NONE); end end Events.ImprovementAddedToMap.Add(OnImprovementAddedToMap); print('FARMER loaded'); Can anyone help me getting this to work? Thanks in Advance !!