Hello everyone. This is my first time entering LUA coding; mostly, I've been using XML to create my mods.
The goal of my LUA is simple. I want to:
Here is my code so far. It only checks to see if Athens was captured (as of now). I adopted most of it from the Korea and Mongol scenarios.
When I run my map, I capture Athens and nothing happens. It just takes the city as normal.
Specific questions:
Thank you for any help you can provide!
The goal of my LUA is simple. I want to:
- Identify all preplaced Greek cities on my map.
- When the capital (Athens) is captured, the captor receives 500 Gold and 1 free Social Policy.
- When a regular Greek city is captured, the captor receives 50 Gold for each city.
- Identify Carthage and Rome on the map.
- When Carthage is captured, it checks to see if the captor was Rome, and if it is, Rome wins a Domination victory.
- When Rome is captured, it checks to see if the captor was Carthage, and if it is, Carthage wins a Domination victory.
Here is my code so far. It only checks to see if Athens was captured (as of now). I adopted most of it from the Korea and Mongol scenarios.
Code:
GreeceCities = {
{ -- Athens
X = 57,
Y = 21,
},
{ -- Sparta
X = 56,
Y = 25,
},
{ -- Delphi
X = 54,
Y = 20,
},
{ -- Pylos
X = 53,
Y = 26,
},
{ -- Elis
X = 52,
Y = 22,
},
{ -- Ambracia
X = 49,
Y = 16,
},
{ -- Pharsalos
X = 55,
Y = 15,
},
{ -- Philippi
X = 58,
Y = 13,
},
};
local iGreeceCitiesStart = 1;
local iGreeceCitiesEnd = 10;
local iAthensIndex = 1;
local iCarthageX = 32;
local iCarthageY = 24;
local iRomeX = 37;
local iRomeY = 12;
--------------------------------------------------------------
-- CaptureCapitals
--------------------------------------------------------------
GameEvents.CityCaptureComplete.Add(function(iOldOwner, bIsCapital, iX, iY, iNewOwner)
--local popupInfo = {
--Data1 = 500,
--Type = ButtonPopupTypes.BUTTONPOPUP_TEXT,
--}
local plot = Map.GetPlot(iX, iY);
local cCity = plot:GetPlotCity();
local iNewOwner = cCity:GetOwner();
-- Was this capital Athens?
if (iX == GreeceCities[iAthensIndex].X and iY == GreeceCities[iAthensIndex].Y) then
Players[iNewOwner]:ChangeGold(500);
--popupInfo.Text = Locale.ConvertTextKey("TXT_KEY_SCENARIO_ATHENS_FALLEN", 500);
Players[iNewOwner]:ChangeNumFreePolicies(1);
end
end);
When I run my map, I capture Athens and nothing happens. It just takes the city as normal.
Specific questions:
- Are there any syntax errors in the script?
- How would I place the script into my mod? So far, I opened Content and added: Type: InGameUIAddin, FileName: LUA/VictoryConditions.lua. Is this it? VFS set to true. Is there more to it?
Thank you for any help you can provide!