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

LUA Question: Adding Projects and WMDs to players

Discussion in 'Mod Creation Help' started by Barbarian King, Jan 27, 2018.

  1. Barbarian King

    Barbarian King Chieftain

    Joined:
    May 4, 2010
    Messages:
    311
    Does anyone know if it is possible to add projects or wmds to a player using lua functions? I've found functions to add units, civics, and techs, but haven't been able to find any for adding projects or wmds.
     
  2. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,687
    Location:
    Illinois, USA
  3. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    7,824
    Location:
    France
    Not tested, but to force-start a project in a city you may be able to use this code (from an UI context, during the turn of the player for who/which you want to add the WMD)

    Code:
        local tParameters = {};
        tParameters[CityOperationTypes.PARAM_PROJECT_TYPE] = projectHash;
        tParameters[CityOperationTypes.PARAM_INSERT_MODE] = CityOperationTypes.VALUE_EXCLUSIVE;
        CityManager.RequestOperation(city, CityOperationTypes.BUILD, tParameters);
    you can get the hash using that:
    GameInfo.Projects["PROJECT_BUILD_NUCLEAR_DEVICE"].Hash
    GameInfo.Projects["PROJECT_BUILD_THERMONUCLEAR_DEVICE"].Hash

    for finishing the project, you may try (from a gameplayscript context) :
    City:GetBuildQueue():FinishProgress()
     
  4. Barbarian King

    Barbarian King Chieftain

    Joined:
    May 4, 2010
    Messages:
    311
    Thanks for the suggestion. I'll see if I can get it to work.

    EDIT: I wasn't able to get it to work, but I did use that as a jumping off point to do something else. In the end, I set it to finish the progress of the Manhattan Project and the Nuclear Device project if it detects it is being built in a city belonging to a civilization that is supposed to have these.
     
    Last edited: Feb 5, 2018

Share This Page