CampBell91
Chieftain
- Joined
- Aug 14, 2012
- Messages
- 2
Hi, I'm new to Civ V modding and want to do something relatively simple (to start) with Lua.
First, I don't know Lua per se but I am generally really good at looking at existing code and learning how to do something (and the more I do this, I actually learn how to code as I go along, like I did with python for Civ IV).
The problem with Lua and Civ V is I don't know where to start. For example, with Civ IV I could open up the event manager file, find the OnCityBuilt and know I can add code to that to do something when a city is built. I imagine I can do similar with Lua but I don't know the specific functions or how to word it, (i.e. what to put at the beginning of the file).
Also, Lua files have no OnModSctivated as with XML files, so how do I tell ModBuddy to use the Lua file to begin with?
As to my specific question, I want to place buildings in cities with Lua.
Say I want to do this in my capital as soon as it's built.
From looking at code I see that to find the capital you write something like:
What would I put before that bit of code? Do I have define the capital first, then do when the capital is built add such and such?
Also
How do I place a building after that, is it something like?
Also, one last question (sorry for such a long post) how do I set it to log errors and where do I see the log.
Thanks in advance for all your help!
First, I don't know Lua per se but I am generally really good at looking at existing code and learning how to do something (and the more I do this, I actually learn how to code as I go along, like I did with python for Civ IV).
The problem with Lua and Civ V is I don't know where to start. For example, with Civ IV I could open up the event manager file, find the OnCityBuilt and know I can add code to that to do something when a city is built. I imagine I can do similar with Lua but I don't know the specific functions or how to word it, (i.e. what to put at the beginning of the file).
Also, Lua files have no OnModSctivated as with XML files, so how do I tell ModBuddy to use the Lua file to begin with?
As to my specific question, I want to place buildings in cities with Lua.
Say I want to do this in my capital as soon as it's built.
From looking at code I see that to find the capital you write something like:
Code:
for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do
local pPlayer = Players[iPlayer];
if (pPlayer:IsEverAlive()) then
if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_XXX) then
local pCity = pPlayer:GetCapitalCity();
What would I put before that bit of code? Do I have define the capital first, then do when the capital is built add such and such?
Also
How do I place a building after that, is it something like?
Code:
if (pCity ~= nil) then
pCity:SetBuildingType(GameInfoTypes["BUILDINGCLASS_GARDEN"]);
Also, one last question (sorry for such a long post) how do I set it to log errors and where do I see the log.
Thanks in advance for all your help!