Ok, lets take it from the top:
Code:
#Scenario name: Rhye's and Fall Realism, by The Turk
This is a comment line as indicated by the # sign. It does absolutely nothing but is included for informative purposes only. I'll skip the rest of these commented lines as they are self-explanatory.
Code:
from PyScenario import Trigger
from Consts import *
These are Python commands - import statements. The first one enables you to use PyScenario Triggers (see below) and the second one fetches Rhye's constant variables from the Consts.py file (referred to as the Consts module in the following text). You should probably open up this too with a text editor to see what it contains, because I'll be using some of the constants in my Triggers. (You can use the actual numerical values also, at the variable is only pointing to that value.)
Code:
# spawn Baghdad (AI only)
Trigger(iArabia).check().year(762).valid().city(77,40,"Baghdad").garrison()
Trigger().year(762).valid().city(77,40,"Baghdad").garrison()
Now its getting a bit hairy, so please try to follow:
The two lines above are "Triggers". A Trigger consists of different settings and "Conditions" and "Actions". If all the Conditions pass, then all the Actions are fired. This is the principle.
If we start with Trigger(iArabia) it means that the "target player" (or Civ) of the entire Trigger is the Arabian Civ. The value iArabia is a constant found the the Consts module (see above).
The Trigger "method" check() is a Condition and it is used to limit Triggers to AI Civs only and alive Civs only. (These settings can be changed individually though.) Here we are using it to prevent the human Arabia player from spawning the city.
The next Condition is year() and the value inside the parenthesis is the the actual game year. This means that the Condition will only pass on the game turn that corresponds the this date.
Next we use the valid() Condition to make sure the spawn tile (see below) is "valid" - that there are no cities or enemy units blocking the spawn. (Because then things could get a bit unreliable.) There are many ways of customizing this Condition but since we only use the default values we don't have to enter any "arguments" or values.
Now we move on to the Actions and the main one is city(). This will spawn a city at the specified coordinates. If you change the values 77 and 40 you can also change the location of the spawn. The third argument is the city name and as its a "string value" it must be expressed within quotations.
The last method is the garrison() Action and it will spawn 2 defensive units on the target tile. In this Trigger the target tile was defined by the city() Action, so this will also be the coordinates for the unit spawn. Unfortunately the default defensive units early on are mostly Warrior units, so you might wanna change this to a specified unit type instead. You do this by changing the eType argument to another value:
Code:
garrison(eType=iLongbowman)
(The iLongbowman constant is found in the Consts module and the unit's indexed value is 60. This is also a valid value. To change the number of units you use iNum=.)
The next Trigger is almost identical to the first one, but there are some differences. It is included as a backup if the first one doesn't fire - and it won't if the Arabs are controlled by the human player. In that case there will be another spawn. Since I haven't specified a target player in the Trigger() constructor, the application will choose a random minor Civ instead. (You could specify this yourself, though. You can find the values for all Civs in the Consts module.)
There is no check() Condition either, as there is no target player to check.
Code:
# spawn Muslim missionaries
Trigger(iTurkey).turn(249).units(70,43,iIslamicMissionary,3)
Trigger(iMali).turn(220).units(53,31,iIslamicMissionary,2)
These Triggers are similar and you can probably figure out some of what they do. The turn() Condition is similar to the year() Condition I used earlier. (There are more settings available though.) Instead of the garrison() method we use the units() method to spawn the units. Its actually quite similar to the city() method as the first to arguments are the map tile coordinates, and the third one is the unit type. I found both the coordinates and the iIslamicMissionary variable in - you guessed it - the Consts module. The last argument is the number of units, and you can easily edit this yourself.
Code:
# re-spawn Persia - with missionaries
Trigger(iPersia).check(bDead=True).year(1501).units(82,39,iIslamicMissionary,3).target((79,37),(85,44)).flip(bMinorsOnly=False).garrison().stability(40)
This last Trigger actually achieves two things, but this is due to a "glitch" in the game. First I use some methods described in earlier Triggers to spawn missionaries for the Persian Civ. The interesting part - the glitch - is that when you spawn something for a dead civ - and we can by setting the bDead argument to the value "True" in the check() Condition - then that Civ is immediately resurrected!
The second part of this Trigger begins with the target() method which can be a bit tough to grasp at first. But it contains a pair of map tile coordinates (both in the form a "tuple") defining a rectangular map area. The first tile is the lower left corner of the area, and the second tile is the upper right corner. (I found these coordinates in the Consts module and they correspond to the Persian "Core Area".) You can of course change these coordinates to whatever area you want!
The actual flipping of cities is done with the flip() Action. Since we defined an entire map area (above) every city within this area will flip. I guessed that you also wanted human controlled cities to flip, so I changed the bMinorsOnly argument to a non-default value ("False"). The garrison() Action spawns units in all Persian cities in the defined area, and lastly the stability() Action adds 40 stability points to the target player (defined as Persia) - in case they originally collapsed due to instability.
A full-length tutorial and a API (reference) for all Trigger methods are available in the
main PyScenario thread. Refer to this documentation as your first aid - and ask for help once you fail to find the information you need.