First I think I have to write in my object.lua file the terrain types I'm currently using. I would use the civ.getTerrain() command. As an example I would use this command for the desert terrain tile:
Code:
object.rDesert = civ.getTerrain(0)
(I used the prefix 'r' for terrain because 't' is already forgiven.)
Just so it's clear, adding object definitions is never
required. But using named objects like this is a good idea and generally a best practice, because it makes code more readable.
My proposal would be to use the prefix 'b' for
baseterrain objects and the prefix 'r' for
terrain objects.
If you want to find the object for "Desert", though, that feels to me like
baseterrain 0, not
terrain 0. So instead of what you wrote, I would add this line to object.lua:
object.bDesert = civ.getBaseTerrain(0, 0)
Note that
civ.getBaseTerrain() takes
two parameters, not one: the first is the map number, and the second is the terrain type or key. (And
civ.getTerrain() takes
three parameters: the first is the map number, the second is the terrain type or key, and the third is the resource number: 0 (no resource), 1 (first resource), or 2 (second resource).)
But after that I unfortunately don't know what to do. One small example of a script code is often enough for me to understand. But please only if someone of you have the time for it. If it is too much time consuming for you than it's not necessary.
What I would like to realize is a change of one or two terrain tiles if a certain city or technology is researched.
Setting aside the condition for the moment, here's how to handle the effect.
First, let's find a tile you want to change, and assign it to a variable:
local tileToChange = civ.getTile(10, 15, 0)
The parameters in the call to
civ.getTile() are the x, y, and z (map) coordinates of the tile.
Then, change the base terrain of that tile:
tileToChange.baseTerrain = object.bDesert
That's all there is to it!
In order to set up the condition, there would probably be more references to entries in the object table. But if the right objects were defined, something like this ought to work:
Code:
if object.cAthens.owner == object.tRomans then
local tileToChange = civ.getTile(10, 15, 0)
tileToChange.baseTerrain = object.bDesert
end
But realize this will change the terrain at that tile on
every turn (well, every time this piece of code is run) while the city of Athens is owned by the Romans -- over and over again. If the tile is
already Desert, you wouldn't notice a change of course, but the event is still running and setting it. So this may not be a reasonable condition for this effect, or you might want to use
civlua.justOnce(), etc.
Hope this is helpful!