I'm trying to set up a wonder that gives a free tech to every civilization when built. I'm very comfortable with the XML portions of modding.
This is a Free Tech similar to the Great Library free tech - you get a popup that lets you choose one tech.
I've started by trying to set it up through the FireTuner lua console as a command. I've been testing by using the FireTuner feature allowing me to switch from player to player.
I can successfully grant a free tech to everyone, and give a notification if the player is human. I can't get the AI to actually spend its free tech. I assume I'm missing a call somewhere, but after some digging, I can't find anything that looks very promising.
The code I've been using is:
Anyone have any ideas? EDIT: Also, if you see that I'm doing something silly unrelated to my question, please point it out. I'm using this as an entry point to learn Lua and especially how Civ 5 uses it. I'm a competent scripter but not a programmer or anything.
EDIT2: Accidentally pasted an older version of the code. Fixed.
This is a Free Tech similar to the Great Library free tech - you get a popup that lets you choose one tech.
I've started by trying to set it up through the FireTuner lua console as a command. I've been testing by using the FireTuner feature allowing me to switch from player to player.
I can successfully grant a free tech to everyone, and give a notification if the player is human. I can't get the AI to actually spend its free tech. I assume I'm missing a call somewhere, but after some digging, I can't find anything that looks very promising.
The code I've been using is:
Code:
i = 0;
for i = 0, GameDefines.MAX_CIV_PLAYERS-1, 1 do
if Players[i]:IsEverAlive() then
local pPlayer = Players[i];
pPlayer:SetNumFreeTechs(pPlayer:GetNumFreeTechs() + 1);
if (pPlayer:IsHuman()) then
pPlayer:AddNotification(NotificationTypes.NOTIFICATION_FREE_TECH, "Choose Free Tech", "Free Tech");
end
end
i = i + 1;
end
Anyone have any ideas? EDIT: Also, if you see that I'm doing something silly unrelated to my question, please point it out. I'm using this as an entry point to learn Lua and especially how Civ 5 uses it. I'm a competent scripter but not a programmer or anything.
EDIT2: Accidentally pasted an older version of the code. Fixed.