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

Plot:ChangeBuildProgress() seems don't work

Discussion in 'Civ5 - Creation & Customization' started by maxf, Sep 5, 2020.

Tags:
  1. maxf

    maxf Chieftain

    Joined:
    Jan 4, 2019
    Messages:
    59
    Gender:
    Male
    Has anyone used this method of Plot object? I wrote test lua module:

    Code:
    function RoadBuilding (iPlayer, iUnit, iX, iY, iBuild, bStarting)
        local pPlot = Map.GetPlot(iX, iY);
        print (iBuild, bStarting, pPlot:GetBuildProgress(iBuild))
        if bStarting then
            local pPlayer = Players[iPlayer]
            local ret = pPlot:ChangeBuildProgress(iBuild, 2000, pPlayer:GetTeam())
    --        ret = pPlot:ChangeBuildProgress(iBuild, 200)                            -- this also don't work
            print ('S', ret, pPlot:GetBuildProgress(iBuild))
        end
    end
    
    GameEvents.PlayerBuilding.Add(RoadBuilding)
    
    And after several turns got such output:
    0 true 90
    S false 90

    0 false 180

    0 false 270

    and so on. As we see, no progress changing after using ChangeBuildProgress() method. In game also no changing in remaining turns. What сould be wrong here?
    P.S. I use VP mod.
     
    Last edited: Sep 5, 2020
  2. maxf

    maxf Chieftain

    Joined:
    Jan 4, 2019
    Messages:
    59
    Gender:
    Male
    Hmm, but in this situation it works fine:

    Code:
    function MeddisTotiks_Worker(iPlayer)
        local pPlayer = Players[iPlayer]
        if (pPlayer:GetCivilizationType() == iCiv and pPlayer:IsAlive()) then
            for pUnit in pPlayer:Units() do
                if pUnit:IsHasPromotion(GameInfoTypes["PROMOTION_DUX_CIVITATIS"]) then
                    local meddisplot = pUnit:GetPlot()
                    for unit in pPlayer:Units() do
                        local unitplot = unit:GetPlot()
                        local workrate = unit:WorkRate()
                        if meddisplot == unitplot and workrate > 0  then
                            local iCurrentBuildID = unit:GetBuildType()
                            if iCurrentBuildID ~= -1 then
                                unitplot:ChangeBuildProgress(iCurrentBuildID, 2*workrate);
                            end
                        end
                    end
                end
            end
        end
    end
    if JFD_IsCivilisationActive(iCiv) then GameEvents.PlayerDoTurn.Add(MeddisTotiks_Worker) end;
    
     
  3. maxf

    maxf Chieftain

    Joined:
    Jan 4, 2019
    Messages:
    59
    Gender:
    Male
    Well, I did some tests and I found that this method is applied at the end of the turn. And only one BuildType per turn per tile allowed.
     

Share This Page