I'm putting together a sort of Lua template, which is to say a collection of useful modules that are already joined together to form a basis for scenario building (or converting) with Lua.
One of those modules is a module to automatically produce production restrictions available through civ.scen.onCanBuild. If you'd like features included in such a module, now would be a good time to ask.
I'm using Imperialism II as a testing scenario, since Imperialism has a lot of very natural building restrictions.
I've done a few things in this example/test. One thing of note is that I have a field that only allows a unit to be built if no units in a list can be built in that city. I changed the Militia unit so all tribes can build it, but the British and French can only build it in cities where they can't build their Riflemen/Voltigeurs. Another field makes it so Marines can only be built in cities that can also build either a Rifleman or a Voltigeur. So the French can build Marines in Brest, but the British can't, if they capture it, all with a relatively simple condition.
Freighters need a Steel Mill and World Port in the city.
Steel Mills need a size 8 city to be produced, and the city must have a bank. Grand Railway stations must have 2 of World Port, Factory, Light Industry.
canBuildSettings.lua is the file where the build restrictions are defined.
One of those modules is a module to automatically produce production restrictions available through civ.scen.onCanBuild. If you'd like features included in such a module, now would be a good time to ask.
I'm using Imperialism II as a testing scenario, since Imperialism has a lot of very natural building restrictions.
I've done a few things in this example/test. One thing of note is that I have a field that only allows a unit to be built if no units in a list can be built in that city. I changed the Militia unit so all tribes can build it, but the British and French can only build it in cities where they can't build their Riflemen/Voltigeurs. Another field makes it so Marines can only be built in cities that can also build either a Rifleman or a Voltigeur. So the French can build Marines in Brest, but the British can't, if they capture it, all with a relatively simple condition.
Freighters need a Steel Mill and World Port in the city.
Steel Mills need a size 8 city to be produced, and the city must have a bank. Grand Railway stations must have 2 of World Port, Factory, Light Industry.
canBuildSettings.lua is the file where the build restrictions are defined.