They're called parameters; they're the objects (an object such as a player, a city, a tile, a unit, etc.) that an event already has defined - or something like that. And you use an event to call a Function (or Function to call other Functions, but that's probably not relevant to you at the moment).
What you call these parameters doesn't matter - except for easy reference. You can call iPlayer, for instance, "afdadajbdsdb", but it will always refer to a particular object. In this case, a player object - or one of the civs on the map.
You can tell what the object is by checking the wiki and looking at the events. For instance, GameEvents.CityCaptureComplete(PlayerID
player, int
capital, ResourceType
x, ResourceType
y, PlayerID
newPlayer, int conquest, int conquest) tells us that the parameter in the first place (named
player) is a player object. You'll notice a second playerID further down. Investigating the use of this event in game files can show that this playerID is the player that just conquered the city, but you can probably infer that by what it's called:
newPlayer.
Capital is a boolean - a true or false check - to see if the captured city was a capital (this sort of thing isn't quite as inferable, but the wiki indicates what it is for if you're every stumped), and
x and
y are the map co-ordinates of the city.
With this information, you fill the function with these parameters, like so:
Code:
function FunctionWhatever(player, capital, x, y, newPlayer, conquest, conquest)
So we have a playerID for the player that just had their city conquered, a check for if the city was a capital, the x and y co-ordinates of the city, another playerID for the player that just conquered the city, and I'm not certain what the last two parameters are for... You must fill in all parameters, yes, but you don't need to define them all as variables (more on that a bit below). However, the above is functionally the same as what you had - but written in a clearer way*:
Code:
function FunctionWhatever(iOldOwner, bIsCapital, iX, iY, iNewOwner, iPop, bConquest)
Then you just tell the event to fire this function whenever the event occurs:
Code:
GameEvents.CityCaptureComplete.Add(FunctionWhatever)
With regard to variables, you'll use these to define objects and you'll always want to define any parameters that you're going to use as a variable. If you're not going to use it, though, you don't need to define it - such as the conquest parameter above. This is useful as you might need specific objects that aren't already defined. For instance, you might want to find out how much gold a player currently has. You would do this by defining a variable for the player object (there's almost always a player object parameter in an event), like so:
Code:
local player = Players[playerID] [COLOR="Red"]-- playerID is the name of the parameter, and it is contained within the player index ([B]Players[][/B]); although I don't understand this part well enough to explain further. Nonetheless, you'll need to do this, as many methods of retrieving other data will not work with just ID of the player.[/COLOR]
With that, you may define another variable in order to find the amount of gold the player has:
Code:
local playerGold = player:GetGold() [COLOR="Red"]-- player is the variable we've just defined, and GetGold() is a method (a function that belongs to a specific object, such as the player object).[/COLOR]
Of course, you don't necessarily need to define playerGold if that's all you're looking for, but if you intend to use that data in a more complex method (such as player:ChangeGold(playerGold), which would double the amount of gold a player has, as it would add to a player's current treasury what we defined as playerGold), it's best to localise it for performance reasons and praticality.
Hopefully I've explained it clearly enough; and hopefully I'm not too off the mark when it comes to what I've explained. It's taken a long time for me to wrap my head around a lot of the basic stuff for Lua and for the most part it's through trial and error; so don't let the task of learning to code in it get too daunting - you'll get there with enough perserverance. But it's highly satisfying when something comes to your understanding. So good luck and feel free to leave any more questions behind and I'll try to answer them.
*the letters in front of each parameter is called Hungarian Notification and it is used to indicate what a parameter is. i = an integer, b = a boolean, etc. You can find more info here:
http://modiki.civfanatics.com/index.php/Civ5_API_FAQ. But of course it's only used as a label - this is something that confused me a lot before I learnt this