1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Build Restrictions Module Preview

Discussion in 'Civ2 - Scenario League' started by Prof. Garfield, Jan 10, 2020.

  1. Prof. Garfield

    Prof. Garfield Deity Supporter

    Joined:
    Mar 6, 2004
    Messages:
    2,635
    Location:
    Ontario
    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.
     

    Attached Files:

    McMonkey, Civinator and JPetroski like this.
  2. CurtSibling

    CurtSibling ENEMY ACE™ SLeague Staff Supporter

    Joined:
    Aug 31, 2001
    Messages:
    28,761
    Gender:
    Male
    Location:
    Innsmouth
    Nice - I like the idea of restrictions in this example. I will keep an eye on developments here, as I move closer to using Lua in some 2020 projects.
     
  3. JPetroski

    JPetroski Deity

    Joined:
    Jan 24, 2011
    Messages:
    2,457
    Does everything that is included in this module work as best as you know? I'd like to use it for Cold War.
     
  4. Prof. Garfield

    Prof. Garfield Deity Supporter

    Joined:
    Mar 6, 2004
    Messages:
    2,635
    Location:
    Ontario
    Download my Lua Code Library and take the module from there. More features were added, and things were fixed. The imperialism file there will also have more examples.
     

Share This Page