Plot:ChangeBuildProgress() seems don't work

maxf

Chieftain
Joined
Jan 4, 2019
Messages
60
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:
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;
 
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.
 
Back
Top Bottom