Given some of the ongoing discussion re scripting events, thought it might be useful to start a short tutorial thread re scripting ideas for this game.
Its my belief that any game of PoN requires some scripting. Some is to do with event chains that fizzle out (such as giving Garibaldi more time to capture Sicily). Hopefully this will be caught over time in patches, but also I think you often will want to make something happen that is not going to occur as a natural result of the game engine. Learning to do simple scripts really does improve your enjoyment, but its not obvious (at the start) how to use the syntax.
My assumption is you want to do something relatively simple to ensure the game engine gives you a desired result. I'm not going to cover the more complex stuff around creating event chains and so on.
Second, this doesn't replace the wiki and in particular you need to reference this invaluable resource for syntax and titles. Having said that, I make a lot of use of taking existing events and reworking to suit me. The Balkan and Mahdi event chains are exceptionally useful for this as both create new countries (and their infrastructure) in game so if you want to create units/structures/force pools or transfer regions you'll inevitably find something close to what you want there.
The basic structure is easy (hah)
You start with 3 lines of code that introduce the event; you add the 'Actions' and you tell it 'End Event'. You can add triggers, conditions and tests as well as probabilities and time limits, but as above, here I am assuming it is simply something you want to happen in a particular way.
The image below is taken from my SP game, and shows the return of Egyptian prisoners of war. As such, it has no in-game effect, its just a bit of housekeeping. You could complicate by in turn, adding a proportion of those returned PoWs back into that nations forcepool.
Even the simpler scripts can trip you up. One is if you create a new structure, then, after each one, you must have the instruction apply. If you only put this at the end of a list, then only the last one will be built. I found this out the hard way when in the mid-1860s I was trying to run a script to improve the AI's exploitation of its coal resources.
So a typical, build this command looks like:
[HTML]SelectFaction = $CMN
SelectRegion = $Glasgow
StartEvent = sugar for Glasgow|1|1|Null|Null|$Glasgow|NULL
Actions
SelectFaction = $GBR
SelectRegion = $Glasgow
CreateStruc
SetType = $Sugar1
SetName = IrnBru rots your teeth
Apply
EndEvent[/HTML]
If you ran this, I'm not sure what would happen (there is no sugar resource in Glasgow) but it gives you the idea. The game fails to take account of the West coast of Scotland only requiring 3 essential food groups - sugar, fat and alcohol, so this corrects for that terrible oversight and creates the Irn Bru factory (I realise that to any non-Scottish reader this will make little sense).
I could then add, say a rum factory and that means I am meeting 2 essential local needs.
A few notes. I find the proper region names from the 'Areas' file (in the game data directory) as I've found the displayed name on the map is not always the title to use for scripting. That file, since it ties regions to wider areas, is by far the easiest way to find the correct info.
Hope this helps a little, and that others can add to, or elaborate.
Kensai, if you want to put it into the wiki, I'm more than happy.
Roger