Would you mind taking a look at this code? I'm having trouble getting it to work, and I'm not very familiar with lua. I slightly edited your code from your virtues Mod to this:
function MantleAbility(playerID)
local player = Players[playerID];
local perk = GameInfo.PlayerPerks["PLAYERPERK_STARRYNITE_SCIENCE_FROM_CULTURE"].ID;
if(player:HasPerk(perk)) then
local bonus = math.floor(player:GetTotalCulturePerTurn() / 2);
if(bonus > 0) then
player:ChangeScience(bonus);
-- Send a notification to the player
local text = Locale.ConvertTextKey("TXT_KEY_STARRYNITE_SCIENCE_FROM_CULTURE_NOTIFICATION", tostring(bonus));
player:AddNotification(NotificationTypes.NOTIFICATION_GENERIC, text, text);
end
end
end
GameEvents.PlayerDoTurn.Add(MantleAbility);
Then for the xml I have is this (I don't think there's anything wrong here, but just in case)
<Buildings>
<Update>
<Set Help="Gain [ICON_RESEARCH] Science income equal to 50% of global [ICON_CULTURE] Culture income."
FreePlayerPerk="PLAYERPERK_STARRYNITE_SCIENCE_FROM_CULTURE"
EnergyMaintenance="0"/>
<Where BuildingClass="BUILDINGCLASS_MANTLE"/>
</Update>
</Buildings>
<PlayerPerks>
<Row>
<Type>PLAYERPERK_STARRYNITE_SCIENCE_FROM_CULTURE</Type>
<Help>Gain [ICON_RESEARCH] Science income equal to 50% of global [ICON_CULTURE] Culture income.</Help>
</Row>
</PlayerPerks>